This is a quick guide that documents how to start developing plugins for Xcode4. You need to have Xcode installed to create plugins.
Step 1 - Xcode Plugin Project Template
- Grab the Xcode project template for creating plugins from here
- Create the plugin template folder
~/Library/Developer/Xcode/Templates/Project Templates/Application Plug-in/Xcode4 Plugin.xctemplateif it doesn’t already exist.
- A quick way to do this is with the following command
mkdir -p "~/Library/Developer/Xcode/Templates/Project Templates/Application Plug-in/Xcode4 Plugin.xctemplate"
- Copy the contents of the GitHub repository to the folder you just created.
- Restart Xcode.
Step 2 - Create a test project
- Open Xcode, and select
File > New > Project
- Then under
OS X > Templatestap
Xcode4 Plugin(shown below)
From the GitHub repo:
The default plugin file links against AppKit and Foundation, and, when built (and Xcode is restarted), creates a menu item labeled "Do Action" in the File menu. Pressing the menu item should open an alert. Customize at will!
If we run the project we just created, it will automatically build and copy the plugin to the right location. In this case it is
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/[Project Name].xcplugin. Restarting Xcode, we get a new menu item under the
When we click on the menu item, we get an alert:
- Xcode plugins have to be written using Objective-C GC, this means you have to use
releasecalls in your code. (No ARC support).
Where to go from here?
- This StackOverflow answer has some great ideas on where to go next
- You can get a dump of the private headers that Xcode uses by using the class-dump tool
brew install class-dumpis the quickest way to get it if you have homebrew installed.
- IDEKit and IDEFoundation are present at
- DVTKit and DVTFoundation are present at
- By registering an observer for
nilyou can see all the notifications that are being called. This is useful to find out which actions are called and when, and what notifications you might need to listen for.