Can you insert separators into the generated menu items for an Xcode extension's commands (under 'Editor' menu)?

258 views Asked by At

When writing an Xcode extension, any commands you define automatically appear as one long list under Xcode's 'Editor/' menu.

For instance, if you define an extension called 'My First Xcode Extension' with eight commands, it appears like this...

Xcode
  ├── File Menu
  ├── Edit Menu
  ├── View Menu
  ├── Find Menu
  ├── Navigate Menu
  └── Editor Menu
      ├── My First Xcode Extension <-- Your extension appears here
      │   ├── Command1             <-- All your commands are listed here
      │   ├── Command2
      │   ├── Command3
      │   ├── Command4
      │   ├── Command5
      │   ├── Command6
      │   ├── Command7
      │   └── Command8
      └── Some Other Extension
          ├── CommandA
          └── CommandB

However, some of the commands are related, so I want to group them, like this...

Xcode
  ├── File Menu
  ├── Edit Menu
  ├── View Menu
  ├── Find Menu
  ├── Navigate Menu
  └── Editor Menu
      ├── My First Xcode Extension
      │   ├── Command1
      │   ├── Command2
      │   ├── --------   <-- Need separator here
      │   ├── Command3
      │   ├── Command4
      │   ├── Command5
      │   ├── --------   <-- and here
      │   ├── Command6
      │   ├── Command7
      │   └── Command8
      └── Some Other Extension
          ├── CommandA
          └── CommandB

Here's an example of what I'm after class Extension: NSObject, XCSourceEditorExtension {

    var commandDefinitions: [[XCSourceEditorCommandDefinitionKey:Any]] {

        return [

           [XCSourceEditorCommandDefinitionKey.classNameKey  : String(reflecting:FirstCommandClass.self),
            XCSourceEditorCommandDefinitionKey.identifierKey : "doSomething",
            XCSourceEditorCommandDefinitionKey.nameKey       : "Do something cool"],

           [ // What goes here to create a separator...],

           [XCSourceEditorCommandDefinitionKey.classNameKey  : String(reflecting:SecondCommandClass.self),
            XCSourceEditorCommandDefinitionKey.identifierKey : "doSomethingElse",
            XCSourceEditorCommandDefinitionKey.nameKey       : "Do something else just as cool"]
        ]
    }
}

Is it possible to add a separator?

1

There are 1 answers

7
Chris Hanson On BEST ANSWER

That’s not currently supported.