Xcode 4 plugin development

后端 未结 6 2004
忘掉有多难
忘掉有多难 2020-11-30 19:59

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条回答
  •  星月不相逢
    2020-11-30 20:37

    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;
    }
    

提交回复
热议问题