Carthage 集成
1.安装carthage
$ brew update
$ brew install carthage
2.更新carthage
$ brew upgrade carthage
$ brew cleanup carthage
更新并删除了历史版本
3.查看当前版本号
$ carthage version
0.24.0
Carthage 使用
1.前往项目,创建并编辑Cartfile
$ cd ~/.../yourProjectFolder
$ touch Cartfile
$ vim Cartfile
文件格式参考:
github "SomeName1/SomeSDK1" ~> 1.0
github "SomeName2/SomeSDK2" ~> 1.0
...
2.下载三方库
全部更新和部分更新
$ carthage update
$ carthage update SomeSDK1 SomeSDK2 ...
下载的框架所在位置是yourProjectFolder/Carthage/Build/iOS/
3.配置三方库
- 选择
Targets->General->Linked Frameworks and Libraries - 点击
+,选择Add Other... - 选择对应的三方库
.framework,添加到项目中 - 选择
Targets->Build Phases,点击+号,选择New Run Script Phase - 在
shell下方的content区域中写入/usr/local/bin/carthage copy-frameworks - 在
Input Files中,添加之前选择的所有三方库,格式为$(SRCROOT)/Carthage/Build/iOS/SomeSDK1.framework - 在
Output Files中,同样添加之前选择的所有三方库,格式为$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SomeSDK1.framework
恭喜恭喜,配置成功~!
4.代码中使用
import SomeSDK1
SomeSDK1.someMethod(someValue)
// or
someMethod(someValue)
5.carthage创建
使用carthage创建,必须前提是有一个代码仓库,我们使用的是github。
打好tag,push到github上对应的tag,就可以了...