02.使用Carthage替代CocoaPods
官方地址: https://github.com/Carthage/Carthage 参考文章: https://www.jianshu.com/p/76b9ff09f99c
集成
通过 Homebrew 安装
Homebrew 安装brew install carthage项目配置文件
和使用CocoaPods一样, 这里也需要一个无后缀的配置文件 Carthfile
配置依赖库
熟悉Podfile的话这里就不会陌生了
github "Alamofire/Alamofire"对于
github指名后会去github上找对对应的库格式:
github Username/ProjectName
git支持http://git://ssh://
==毫无疑问是说必须为指定版本,如果没有,就不下载编译;>=使用大于或等于指定版本的库,如果有最新,则使用最新的;~>则是一个开区间,如“~>1.1.0”则会返回“1.1.1~1.9.9”之间的版本,不包括2.0.0;
编译第三方库
类似pod install操作, cd 到工程目录执行下面命令
carthage update --platform iOS一般这里指定一下平台好些,否则会编译出mac,tv,iOS个平台的,完全没必要
执行完成后会看到有个
Carthage目录
build中就是编译好的第三方库Checkouts中是第三方库的缓存
导入第三方库
手动将Carthage/Build中的framework加到项目中
先在就阔以在项目中使用Alamofire咯
一些坑
01: has no shared framework schemes
*** Skipped building R.swift due to the error:
Dependency "R.swift" has no shared framework schemes for any of the platforms: iOS因为
Carthage需要库工程的Scheme需要为Shared没有的话可能是因为
git忽略了相应文件xcuserdata
参考
https://stackoverflow.com/questions/35054788/carthage-no-shared-framework-schemes-for-ios-platform-for-my-own-framework https://www.jianshu.com/p/a7defcf2e327
Last updated
Was this helpful?