I've been looking all over the place but I can't find anything. Does anyone know how to create an Xcode 4 plugin?
6 Answers
As far as I know there is no official way to create Xcode 4 plugins (just like there wasn't one for v3.x).
Here is an openradar on Xcode's lack of plugin support:
Please support the ability for 3rd parties to extend Xcode via a public plugin API. Aperture, Visual Studio, Eclipse, TextMate and other applications benefit from this ability. I would like to see more advanced refactorings, code analysis (think Resharper by Jetbrains) and modeling.
Please dupe this if you want plugins!
Edit: Just stumbled upon this:
Cédric Luthi: "Xcode 4 does support user-defined plugins, see CLITool-InfoPlist for an example of a working Xcode 4 plugin. You just have to add XC4Compatible (true) in the Info.plist."
https://github.com/0xced/CLITool-InfoPlist
That being said these GitHub repos might be handy, too:
Xcode4 Plugin-API Documentation (link dead)
Xcode Plugin Template (link updated)
Further more mogenerator's Xmod plugin might be a good starting point.
(Wasn't Xcode-4 compatible yet, last time I checked, though)
-
@Radu: Just added a link to my answer in which Cédric Luthi (aka 0xced) states that it is in fact possible to build plugins for Xcode 4. Jun 11, 2011 at 16:10
-
@Regexident, I see. This lack of support is quite unfortunate. Thanks a lot for the links. Also, updated question, looking for an easier way.– ridJun 11, 2011 at 16:14
-
This might probably be better fitted as a separate question. To keep this question on topic and an easy lookup on Xcode plugins for others to come. Jun 11, 2011 at 16:17
-
@Radu: Thanks. Then this question should hereby be answered, I guess. ;) Mind to accept it? (Btw, I already posted to your follow-up question. Had some time to write up an answer for that one after all :P) Jun 11, 2011 at 16:42
-
1XC4Compatible solution works just fine! We updated our XcodeColors plugin for Xcode 4 finally: github.com/DeepIT/XcodeColors– UncleMiFJun 29, 2011 at 11:57
Best way to learn is to look at github plugin code (see long list below):
- Basically its a plugin bundle.
- No main.m No MainMenu.xib
- First class loaded by setting NSPrincipalClass in info.plist
- in its init: you register for AppKit notifications
- See the code samples
- some check the mainBundle app id to make sure this is XCode
- The XCode Editor window class is DVTSourceTextView
- Its a subclass of DVTSourceTextView :NSTextView : NSText
- so you can register to listen for its notifications for NSTextView or NSText
- such as NSTextViewWillChangeNotifyingTextViewNotification
Because its not an official standard I noticed each sample loads in different ways.
XCODE PLUGIN SAMPLES
compiled by either searching github/web for
'DVTSourceTextView'
This is the Xcode Editor window class name
or
Info-list key
'XC4Compatible'
https://github.com/omz/ColorSense-for-Xcode
https://github.com/ciaran/xcode-bracket-matcher
- uses a ruby parser run as pipe!
https://github.com/joshaber/WTFXcode
https://github.com/0xced/NoLastUpgradeCheck
http://code.google.com/p/google-toolbox-for-mac/downloads/list
see GTMXcode4Plugin
https://github.com/DeepIT/XcodeColors
https://github.com/0xced/CLITool-InfoPlist
https://github.com/sap-production/xcode-ide-maven-integration
https://github.com/ciaran/xcode-bracket-matcher
TO GET TO THE NSTextView that is the console
https://github.com/sap-production/xcode-ide-maven-integration
- (NSTextView *)findConsoleAndActivate {
Class consoleTextViewClass = objc_getClass("IDEConsoleTextView");
NSTextView *console = (NSTextView *)[self findView:consoleTextViewClass inView:NSApplication.sharedApplication.mainWindow.contentView];
if (console) {
NSWindow *window = NSApplication.sharedApplication.keyWindow;
if ([window isKindOfClass:objc_getClass("IDEWorkspaceWindow")]) {
if ([window.windowController isKindOfClass:NSClassFromString(@"IDEWorkspaceWindowController")]) {
id editorArea = [window.windowController valueForKey:@"editorArea"];
[editorArea performSelector:@selector(activateConsole:) withObject:self];
}
}
}
return console;
}
Have a look at this new plugin: https://github.com/sap-production/xcode-ide-maven-integration. Maybe you can derive some concepts for your plugin.
Yesterday ColorSense for Xcode 4 was released on Github. Since the code is really compact spread over just 3 classes, I think you should take a look over there.
Xcode does not have a public plug-in API.
This was the case with earlier versions, and is the case with Xcode 4 as well.
No, Xcode doesn't support plugins, alternatively you may try AppCode, another IDE for iOS/MacOS, it does support plugins development.
-
That's obviously not true as there are plugins for Xcode available and you can easily write your own if you need. Jan 23, 2014 at 12:30