Is there any documentation for building Xcode 4 plugins?
Recently I’ve noticed a couple of projects on github that extend the functionality of Xcode 4 via plugins.
Two projects as examples by @olemoritz:
- MiniXcode changes the main toolbar.
- ColorSense provides overlays to help pick colours.
Both projects are installed into
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins and Xcode just picks them up.
Are there any sources of documentation (officlal or user generated) on extending Xcode?
Edit: ping @olemortiz 😉
- NSDictionary with ordered keys
- Handling cocoa key events (keys pressed) with swift in a console application
- Count colors in image: `NSCountedSet` and `colorAtX` are very slow
- Save a user popup selection in a custom Automator Action
- When is it better to use an NSSet over an NSArray?
- Programmatically get path to Application Support folder
2 Solutions Collect From Internet About “Is there any documentation for building Xcode 4 plugins?”
As I wrote those plugins you mentioned, here are some pointers:
There is no official documentation from Apple, so while Xcode does have a plugin infrastructure, it is entirely private API. (but hey, no one wants to submit Xcode plugins to the App Store, right? ;)) – The usual warnings apply: You should code very defensively, and it’s possible that Xcode updates break things. Any plugin can bring Xcode down entirely, so be careful.
There is a seemingly abandoned effort to document the plugin interface here.
There are some open source projects that allow you to see what’s needed to get a plugin loaded at all, e.g. mine and there’s CLITool-Infoplist (I think that’s where I got the basic structure from, but I can’t really remember, because I’ve been doing this without publishing anything for quite a while).
You can use class-dump to generate headers from Xcode’s private frameworks, e.g. IDEKit and IDEFoundation (in
Xcode.app/Contents/Frameworks). Reading those gives you quite a bit of information on how Xcode is structured internally. DVTKit and DVTFoundation (in
Xcode.app/Contents/SharedFrameworks) can also be useful to class-dump.
You can observe all notifications that are sent in Xcode by registering an observer for
nil. I initially just logged all those notifications to get an idea of where I might be able to hook into.
There is no formal API or documentation.
Having said that nearly all community plugins are open sourced, use http://alcatraz.io to discover new plugins, then follow their github source code to learn how people are implementing them.
Here are some useful resources:
- Use https://github.com/edwardaux/XcodeExplorer to discover the API hook point you need to be poking around.
- Look at http://www.blackdogfoundry.com/blog/creating-an-xcode4-plugin/ for a series of posts about building Xcode plugins.
- Check https://github.com/kattrali/Xcode-Plugin-Template for a Xcode 6+ template for creating new plugins.
- Look at https://github.com/zats/AdjustFontSize-Xcode-Plugin as a good Xcode 7.1+ starting point
- See http://www.blackdogfoundry.com/blog/debugging-your-xcode-plugin/ for debugging aid
- IOS7 – SLComposeViewController – Error posting to Twitter – cannot send tweet – connection failed
- Is Silent Remote Notifications possible if user has disabled push for the app?
- NavigationBar becomes black on pop
- Fullscreen UIView with Status bar and Navigation Bar overlay on the top
- Method swizzling in swift 4
- Swift days between two NSDates
- AutoLayout: UIView within UIView has incorrect frame
- Synchronization/wait design for cross-thread event signaling (Obj-C)?
- Webkit overflow scrolling touch CSS bug on iPad
- My button's titleLabel become “…” on iOS10
- What are the tradeoffs between performSelector:withObject:afterDelay: and dispatch_after
- What is the availability of NSNotFound?
- Programmatically place partial image over another in UIView using Swift 3
- CGImageCreateWithImageInRect not Cropping Correctly
- check if control center is used