3

I'm looking for some documentation of the new Xcode Source Editor Extensions in Xcode 8.

As far as I can see there is only the "documentation" found in the header file for XcodeKit. Would be great to get something that's more detailed and more official.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
benrudhart
  • 1,406
  • 2
  • 13
  • 25

4 Answers4

2

Very preliminary XcodeKit reference documentation is now available.

Our WWDC 2016 presentation introducing Xcode Source Editor Extensions remains the best walkthrough.

The very shortest version, however, is: Because App Extensions need to be embedded in an application, you need to first create a new macOS Cocoa Application, and then add a new Xcode Source Editor Extension to that application. Then the XcodeKit reference should help some in implementing that.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
  • Hi Chris, great presentation on WWDC! I could not find how the extension is installed (after archiving). I noticed that once I run the App, it will show in the System Preferences under Extension. After that, moving in/out of the trash will show/hide it in System Preferences. Where is the extension getting registered? Is there a file somewhere in the user library (application support or other) that is created when the extension App is launched? – bauerMusic Apr 04 '17 at 08:39
  • 1
    Launch Services keeps track of this. There’s no API to cause an extension to be registered. – Chris Hanson Apr 07 '17 at 02:24
  • 1
    If the Console of the Debug Area has a message similar to "IDEExtensionManager: Xcode Extension does not incorporate XcodeKit:", then go to the target of the extension, tab 'General' > Frameworks and Libraries and add XcodeKit *with* 'embed and sign'. In the template, Apple did add the Cocoa framework, but forgot XcodeKit. – Elise van Looij Dec 29 '20 at 16:02
1

Not really a documentation but a good reference also https://developer.apple.com/videos/play/wwdc2016/414/

Exception
  • 785
  • 8
  • 8
0

Extensions, at the moment, are poorly documented. There are a lot of assumptions made (for example, did you know that you can execute the container app? Yup, it’s really nice for settings GUI - see this How To Execute Container App - Second Answer)

At the moment, there are a lot of things missing: for example, there isn’t a structure that shows the corresponding lines with the data object - though this is quickly created with the following code:

    var matches: [NSTextCheckingResult] = []
    do {
        let regex = try NSRegularExpression(pattern: "\n", options: [])
        matches = regex.matches(in: completeBuffer,
                                options: [],
                                range: NSMakeRange(0, completeBuffer.count))
    }
    catch {

    }

This gives you the location of all the \n’s - you should be able to fill out the rest to give you starting and ending positions which should match up to the lines.

All in all, there is a lot to like about the extension, but there are quite a few things missing as well.

Community
  • 1
  • 1
Lloyd Sargent
  • 599
  • 4
  • 13
-1

Currently the only available documentation is in the headers; there's nothing "unofficial" about them. If you have specific questions, please ask.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
  • Well, that documentation is very terse and spartan, feeling as though it is a quick stand-in for now in lieu of richer documentation in the future. For example, even such basic topics as how the identifierKey-nameKey and classNameKey-identifierKey dictionaries are to be filled out in commandDefinitions array of dictionaries is completely unmentioned. Not even an example to mimic. – Andreas ZUERCHER Dec 14 '17 at 21:44
  • The current official documentation reminds me of a joke a comedian (Stephen Wright?) once told back during the 1980s: guy: What's your phone number? gal: It's in the phone book. guy: Oh, then what is your name? gal: It's in the phone book too. (There's nothing “unofficial” about the phone book, but, just as in the joke, the official reference doesn't really support the use-case very well.) – Andreas ZUERCHER Dec 14 '17 at 21:44