Framework

XcodeKit

Create extensions to add commands to the Xcode source editor.

Overview

Using the XcodeKit framework, you can customize Xcode with source editor extensions to add functionality and specialized behavior to the source editor. Source editor extensions provide a group of editor commands alongside the built-in commands in the Editor menu in Xcode. Source editor extensions can read and modify the contents of a source file, as well as read and modify the current text selection within the editor. Include source editor extensions in developer apps distributed on the Mac App Store.

Topics

First Steps

Add a source editor extension target to an Xcode project and activate its scheme.

Creating a Source Editor Extension

Add and configure a source editor extension in your Xcode project.

Testing Your Source Editor Extension

Launch a special instance of Xcode to test your source editor extension.

protocol XCSourceEditorExtension

The protocol you implement to create Xcode source editor extensions.

Editor Commands

Respond to commands by changing the text contents and text selections in a source editor.

protocol XCSourceEditorCommand

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

class XCSourceEditorCommandInvocation

An object that identifies the command issued to your extension and provides the contents of the active source editor.

Source Text

class XCSourceTextBuffer

A buffer you use to access and modify the text contents and text selections in a source editor.

struct XCSourceTextPosition

A zero-based position in a source editor, defined by a line number and column number.

class XCSourceTextRange

A half-open range of text in a buffer you use to select text or specify the insertion point for new text.

XcodeKit Constants

XcodeKit Version Constants

Determine the version of XcodeKit available in an instance of Xcode.