How to create Xcode plugin
I list here some good references that teach how to build your own Xcode plugin. The best way to build an Xcode plugin is to learn from some with the same functionalities
Find good Xcode plugins
Just search on Google and you’ll find a lot. Some are nice to curate the lists
- Xcode Plugins - NSHipster
- My favorite Xcode plugins
- Best Xcode plugins
- Xcode Plugin Listing – Quality Xcode Plugins
- Complete (more or less) list of Xcode plugins
- A Few Helpful Xcode Plugins
- Alcatraz Alcatraz is an Xcode plugin that manages Xcode plugins
You can also learn from my plugin XcodeWay, which is very simple. It just contains menu items and actions
Tutorial
blackdogfoundry
has some very good tutorials on creating Xcode plugin. Check it out
The only thing he missed is the DVTPlugInCompatibilityUUIDs in your Info.plist
1 |
<key>DVTPlugInCompatibilityUUIDskey> |
Check it this issue Plugin not loaded in XCode 5.1 to find out more about DVTPlugInCompatibilityUUIDs problem
Also, see the talk by Marin (Reference No.8), for more about DVTPlugInCompatibilityUUIDs
Private APIs
You sometime need to use private APIs to create Xcode plugin.
For example, Get the path of current project opened in Xcode plugin
1 |
NSArray *workspaceWindowControllers = [NSClassFromString(@"IDEWorkspaceWindowController") valueForKey:@"workspaceWindowControllers"]; |
Some plugin like ShowInGithub use class-dump to generate the header APIs and include them in their Header Search Path, this way, they can work with private APIs more easily
NSTask
NSTask can help you run command as if you run on the terminal, really powerful. I use it a lot
NSTask tutorial
Cocoa programming
Creating an Xcode plugin means using a lots of Cocoa APIs. You should have some idea of Cocoa programming
Reference
- Xcode Plugins
- Xcode5 Plugin Template
- Creating an Xcode4 Plugin
- Common Xcode4 Plugin Techniques
- Debugging your Xcode plugin
- Alcatraz internals by Marin Usalj
- How To Create an Xcode Plugin
- Writing Xcode plugin in Swift