您能否将分隔符插入 Xcode 扩展程序命令的生成菜单项中(在 'Editor' 菜单下)?
Can you insert separators into the generated menu items for an Xcode extension's commands (under 'Editor' menu)?
编写 Xcode 扩展程序时,您定义的任何命令都会自动显示为 Xcode 的 'Editor/' 菜单下的一长串。
例如,如果您用八个命令定义一个名为 'My First Xcode Extension' 的扩展,它看起来像这样...
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
但是,有些命令是相关的,所以我想把它们分组,像这样...
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
这是我所追求的示例
class 扩展: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"]
]
}
}
是否可以添加分隔符?
目前不支持。
编写 Xcode 扩展程序时,您定义的任何命令都会自动显示为 Xcode 的 'Editor/' 菜单下的一长串。
例如,如果您用八个命令定义一个名为 'My First Xcode Extension' 的扩展,它看起来像这样...
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
但是,有些命令是相关的,所以我想把它们分组,像这样...
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
这是我所追求的示例 class 扩展: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"]
]
}
}
是否可以添加分隔符?
目前不支持。