Xcode 4 插件开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6316921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4 plugin development
提问by rid
I've been looking all over the place but I can't find anything. Does anyone know how to create an Xcode 4 plugin?
我已经找遍了所有地方,但我找不到任何东西。有谁知道如何创建 Xcode 4 插件?
回答by Regexident
As far as I know there is no official way to create Xcode 4 plugins(just like there wasn't one for v3.x).
据我所知,没有创建 Xcode 4 插件的官方方法(就像 v3.x 没有插件一样)。
Here is an openradar on Xcode's lack of plugin support:
这是关于 Xcode 缺乏插件支持的 openradar:
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.
请支持第三方通过公共插件 API 扩展 Xcode 的能力。Aperture、Visual Studio、Eclipse、TextMate 和其他应用程序都受益于这种能力。我希望看到更高级的重构、代码分析(想想 Jetbrains 的 Resharper)和建模。
Please dupe this if you want plugins!
如果你想要插件,请欺骗这个!
Edit: Just stumbled upon this:
编辑:只是偶然发现了这个:
Cédric Luthi: "Xcode 4 does support user-defined plugins, see CLITool-InfoPlistfor an example of a working Xcode 4 plugin. You just have to add XC4Compatible (true) in the Info.plist."
Cédric Luthi:“Xcode 4 确实支持用户定义的插件,请参阅CLITool-InfoPlist以获得工作 Xcode 4 插件的示例。您只需在 Info.plist 中添加 XC4Compatible (true)。”
https://github.com/0xced/CLITool-InfoPlist
https://github.com/0xced/CLITool-InfoPlist
That being said these GitHub repos might be handy, too:
话虽如此,这些 GitHub 存储库也可能很方便:
Xcode4 Plugin-API Documentation(link dead)
Xcode Plugin Template(link updated)
Xcode4 Plugin-API 文档(链接失效)
Xcode 插件模板(链接已更新)
Further more mogenerator's Xmod plugin might be a good starting point.
(Wasn't Xcode-4 compatible yet, last time I checked, though)
更多mogenerator的 Xmod 插件可能是一个很好的起点。
(不过,我上次检查时还与 Xcode-4 不兼容)
回答by brian.clear
Best way to learn is to look at github plugin code (see long list below):
最好的学习方法是查看 github 插件代码(见下面的长列表):
- 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
- 基本上它是一个插件包。
- 没有 main.m 没有 MainMenu.xib
- 通过在 info.plist 中设置 NSPrincipalClass 加载的第一个类
- 在其初始化中:您注册 AppKit 通知
- 查看代码示例
- 一些检查 mainBundle 应用程序 ID 以确保这是 XCode
- XCode 编辑器窗口类是 DVTSourceTextView
- 它是 DVTSourceTextView :NSTextView : NSText 的子类
- 所以你可以注册来监听 NSTextView 或 NSText 的通知
- 例如 NSTextViewWillChangeNotifyingTextViewNotification
Because its not an official standard I noticed each sample loads in different ways.
因为它不是官方标准,我注意到每个样本以不同的方式加载。
XCODE PLUGIN SAMPLES
Xcode 插件示例
compiled by either searching github/web for
通过搜索 github/web 编译
'DVTSourceTextView'
This is the Xcode Editor window class name
这是 Xcode 编辑器窗口类名
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
到达作为控制台的 NSTextView
https://github.com/sap-production/xcode-ide-maven-integration
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;
}
回答by Alexander
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.
看看这个新插件:https: //github.com/sap-production/xcode-ide-maven-integration。也许您可以为您的插件推导出一些概念。
回答by Jens Kohl
Yesterday ColorSense for Xcode 4was released on Github. Since the code is really compact spread over just 3 classes, I think you should take a look over there.
昨天,用于 Xcode 4 的 ColorSense在 Github 上发布。由于代码非常紧凑,仅分布在 3 个类中,我认为您应该看看那里。
回答by Chris Hanson
Xcode does not have a public plug-in API.
Xcode 没有公共插件 API。
This was the case with earlier versions, and is the case with Xcode 4 as well.
早期版本就是这种情况,Xcode 4 也是这种情况。
回答by Greeny
No, Xcode doesn't support plugins, alternatively you may try AppCode, another IDE for iOS/MacOS, it does support plugins development.
不,Xcode 不支持插件,或者您可以尝试 AppCode,另一个适用于 iOS/MacOS 的 IDE,它确实支持插件开发。