打造你專屬的xcode plugin
DESCRIPTION
Build your own Xcode plugin @CocoaHeads TaipeiTRANSCRIPT
打造你專屬的Xcode pluginMichael Chen
KKBOX
Overview
• Xcode plugin template
• 窺探Xcode runtime
• 寫plugin⼀一些⼩小撇步
• 好東⻄西要與好朋友分享
Xcode plugin有百百種...
⾃自⼰己的plugin⾃自⼰己刻
⾃自⼰己的GA⾃自⼰己刻
Xcode plugin簡介• 附檔名為.xcplugin
• 放在~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/
Xcode template• Infos.plist
!
$ defaults read /Applications/Xcode.app/Contents/Info.plist | grep DVTPlugInCompatibilityUUID
DVTPlugInCompatibilityUUID = "A2E4D43F-41F4-4FB9-BB94-7177011C9AED";
Xcode template• 設定Building Settings
參數名稱 值 說明
Installation Build Products Location
${HOME} Product根⺫⽬目錄
Installation Directory
/Library/Application Support/Developer/Shared/Xcode/Plug-ins
這是⼀一個相對路徑,會被上⾯面設定所影響。
Deployment Location YES Installation Directory
Wrapper Extension xcplugin Xcode plugin的附檔名
其實也不⽤用這麼⿇麻煩...https://github.com/kattrali/Xcode5-Plugin-Template
可以開始寫• 新增⼀一個主要class,跟Principal class名稱⼀一樣。
• plugin初始化 + (void)pluginDidLoad:(NSBundle *)bundle
⼩小撇步1• 設定Scheme,讓Xcode⾃自⼰己對⾃自⼰己debug
⼩小撇步2• class-dump xcode
• https://github.com/luisobo/Xcode-RuntimeHeaders
⼩小撇步3• Find a control http://stackoverflow.com/questions/2715534
• 接收所有的通知[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(listenAll:) name:nil object:nil];
• Hack private API swizzle method https://github.com/rentzsch/jrswizzle
⼤大功告成• MCLog - 利⽤用Regular Expression過濾console log
https://github.com/yuhua-chen/MCLog
好東⻄西不分享嗎?
上架吧• GitHub • Alcatraz - The package manager for Xcode.
http://alcatraz.io/ • clone下來 • package.json加上資訊 • 發pull request
Twitter轉發, blog分享
意外收穫
太爽拉!• Trending repositories 成就達成!
謝謝各位!Michael Chen @yuhua_twit