最近在進行Swift 3.0的遷移工作, 其中最讓人頭大的一點就是,搭配xcode 8.2 Swift 3.0 編譯的速度實在是太慢了,嚴重影響了工作效率。
因此決定,將部分cocoapods 轉(zhuǎn)移至 Carthage好處就是xcode clean之后不用重新編譯原本pod中的lib,壞處暫時沒有發(fā)現(xiàn)(Carthage將Swift打包成動態(tài) framework,這一行為在iOS 8之后才被支持,目前我的項目不需要支持iOS7)
開始吧
安裝
- brew update
- brew install carthage
使用
- 創(chuàng)建一個Cartfile
- 如果你在github上看到有需要的lib ,并且支持Carthage的話
- 在Carthfile中添加如下
github "Alamofire/Alamofire"
git "file:///User/yourGitRepoPath" //支持本地已經(jīng)下載的git repo
- carthage update 然后等吧, 反正直接從 github下拉源碼我沒有成功過
,一般我都是先把 git repo clone 到本地之后,再 carthage update --platform iOS - 在會發(fā)現(xiàn)一個 build 文件夾里看到你需要的framework了
- 回到你的項目 target -> general -> linked frameworks and libraries, 把剛才的 framework 加進去
-
最后 Build Phases + New Run Script Phase
Screenshot 2016-12-24 下午5.50.33.png - 重新build一下 enjoy!