安裝Carthage
安裝Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝Carthage
brew install carthage
使用Carthage
- 使用終端進入工程目錄
- 執行命令touch cartfile創建文件
- 編輯cartfile,例如導入Alamofire,github "Alamofire/Alamofire" ~> 4.7
- 執行命令carthage update --platform iOS導入,出現錯誤可以去Xcode的Preferences的Locations中設置Command line Tools
- 項目名稱 --> TARGETS --> General --> Linked Frameworks and Libraries -> Add Other... --> 選擇Carthage/Build/iOS/Alamofire.framework文件 --> 導入成功
- 項目名稱 --> TARGETS --> General --> Build Phases --> 點擊左上角加號 --> New Run Script Phase --> 點開Run Script --> 在Shell下面的黑色框中填入/usr/local/bin/carthage copy-frameworks --> 點擊Input Files下面的加號 --> 爲framework添加訪問路徑$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework --> 完成