Xcode插件开发

一、安装模板

1.git clone https://github.com/kattrali/Xcode-Plugin-Template.git

2.cd Xcode-Plugin-Template

3.mkdir ~/Library/Developer/Xcode/Template

4.mv ./Project Templates/ ~/Library/Developer/Xcode/Template

5.重启XCODE后,会看到模板中多出了OS X-Application Plug-in-Xcode Plugin

二、监听Xcode消息

在插件入口处添加

NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("notificationlog:"), name: nil, object: nil)

对应Selector

func notificationlog(notif:NSNotification) {

        NSLog(notif.name)

}

 

三、安装插件

将生成的xcplugin文件拷贝到~/Library/Application Support/Developer/Shared/Xcode/Plug-ins即可(开发机会在开发过程中自动拷贝过去)