<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XcodeKit",
  "identifier" : "/documentation/XcodeKit/XCSourceEditorCommand",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "XcodeKit"
    ],
    "preciseIdentifier" : "c:objc(pl)XCSourceEditorCommand"
  },
  "title" : "XCSourceEditorCommand"
}
-->

# XCSourceEditorCommand

The protocol you implement to handle command invocations in a source editor extension.

```
protocol XCSourceEditorCommand : NSObjectProtocol
```

## Overview

A one-to-one mapping between command classes and commands is not required—multiple commands can be handled by a single class, by checking their invocation’s `commandIdentifier` at runtime.

## Topics

### Defining Editor Commands

[`XCSourceEditorCommandDefinitionKey`](/documentation/XcodeKit/XCSourceEditorCommandDefinitionKey)

A key in the dictionary that defines a source editor command.

### Handling Editor Commands

[`perform(with:completionHandler:)`](/documentation/XcodeKit/XCSourceEditorCommand/perform(with:completionHandler:))

Performs the action associated with the command using the information in an invocation.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)