標籤:
0x01、首先安裝OSX套件管理器Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
0x02、使用 Homebrew 進行安裝Carthage 安裝之前先對Homebrew進行更新一下 不然可能會安裝到比較老版本的Carthage
brew update
0x03、Homebrew 安裝Carthage
brew install carthage
到這裡已經把Carthage工具安裝完畢
下面是開始使用Carthage工具管理組件(Carthage 是由 Swift 語言寫的,只支援動態架構,只支援 iOS8+。 目前只支援github 或者git 相關管理源的庫)
0x04、添加 Cartfile 檔案 寫法可參數官方例子 (https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md)
如:github "ReactiveCocoa/ReactiveCocoa" >= 2.3.1
0x05、再執行 carthage update ;在執行 carthage update 命令後會在根目錄建立一個 Cartfile.resolved 檔案,這個檔案是產生後的依賴關係,不能修改,同時還會產生一個Carthage 檔案夾 裡面放的是編譯好的.framework檔案
- Cartfile 檔案用來標註你需要哪些依賴庫,對應版本或者 Git 分支 (需要提交到 Git)
- Cartfile.resolved 檔案用來跟蹤項目當前所用的依賴版本號碼,為了保持多端開發一致 (需要提交到 Git)
- Carthage 檔案夾用來存放依賴庫的源檔案和編譯後的檔案 (不需要提交到 Git)
0x06、把編譯好的.framework 檔案同時放到Bild Phases 下面的Link Binary With Libraries裡和General 裡的Embedded Binaries裡
0x07、添加修改.gitignore檔案 添加 Carthage作為忽然檔案夾
例子:https://github.com/yanyan1119/TestCarthage
安裝和使用Carthage