Xcode 4 plugin development

I've been looking all over the place but I can't find anything. Does anyone know where to find documentation on how to create an Xcode 4 plugin?

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.

Provide plugin API for Xcode 4 (rdar://8622025)

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:


Further more mogenerator's Xmod plugin might be a good starting point. (Wasn't Xcode-4 compatible yet, last time I checked, though)


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.


Take a look at this article: Xcode 4: Interface Builder Plugins


No, Xcode doesn't support plugins, alternatively you may try AppCode, another IDE for iOS/MacOS, it does support plugins development.


Need Your Help

Apache 301 Redirect and preserving post data

apache rewrite http-post http-status-code-301

I have implemented SEO URLs using Apache 301 redirects to a 'redirect.cfm' in the root of the website which handles all URL building and content delivering.

InvalidValueError: not an instance of HTMLInputElement

javascript google-maps google-maps-api-3 google-maps-markers google-places-api

FYI, I'm not a JavaScript Ninja but felt like I'll become one when I did a lot of things based on Google Maps recently.