星空网 > 软件开发 > 操作系统

Carthage使用(cocoapods的替代)

1.使用homebrew安装Carthage
brew intsall carthage


 Ps:没有安装Homebrew的话,进入传送门Homebrew。顺便提一句可以选择简体中文啊。
Carthage使用(cocoapods的替代)images/loading.gif' data-original="http://images2015.cnblogs.com/blog/793757/201512/793757-20151218112107693-1437012105.png" />
 
2.进入项目创建
vim Cartfile 


 
Cartfile内容示例如下
  • >= 1.0 for “at least version 1.0” 1.0以上
  • ~> 1.0 for “compatible with version 1.0” 最好是1.0,
  • == 1.0 for “exactly version 1.0” 必须是1.0
  • 什么也不写,默认是最新版本
# Require version 2.3.1 or latergithub "ReactiveCocoa/ReactiveCocoa" >= 2.3.1# Require version 1.xgithub "Mantle/Mantle" ~> 1.0  # (1.0 or later, but less than 2.0)# Require exactly version 0.4.1github "jspahrsummers/libextobjc" == 0.4.1# Use the latest versiongithub "jspahrsummers/xcconfigs"# Use the branchgithub "jspahrsummers/xcconfigs" "branch"# Use a project from GitHub Enterprisegithub "https://enterprise.local/ghe/desktop/git-error-translations"# Use a project from any arbitrary server, on the "development" branchgit "https://enterprise.local/desktop/git-error-translations2.git" "development"# Use a local projectgit "file:///directory/to/project" "branch"

为了简单我只添加了一个 Ps:第一行为注释

#Require version 2.0.0github "Alamofire/Alamofire" ~> 2.0.0


 
3.终端运行
carthage update


 
运行carthage update的结果如下
 
*** Cloning Alamofire*** Checking out Alamofire at "2.0.2"*** xcodebuild output can be found in /var/folders/ps/vkznbcf51bd56ld8j4cby_5m0000gp/T/carthage-xcodebuild.kTo8yR.log*** Building scheme "Alamofire watchOS" in Alamofire.xcworkspace*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace

 


文件目录如下
Carthage使用(cocoapods的替代)
其中文件Cartfile、Cartfile.resolved 和 Carthage文件夹是与Carthage被创建出来的,其他的项目自身带的
 
4.打开 Carthage文件夹 进入Bulid。以iOS为例,进入iOS文件夹找到Alamofire.framework拖到项目中
Carthage使用(cocoapods的替代)
 
或者在项目中选中Target -> Build Phases -> Link Library with Librarie点击+号,然后点击左下角的add Other.. 找到。framework添加就行
Carthage使用(cocoapods的替代)
 
5.添加脚本
在 Build Phases -> +(左上角) -> New Run Script Phase
然后,点开Run Script 添加脚本
/usr/local/bin/carthage copy-frameworks


最后添加"Input Files”(以Alamofire为例)


$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework


如下图所示:


Carthage使用(cocoapods的替代)
 
Carthage使用(cocoapods的替代)
 
添加的脚本的作用
在App Store提交通用二进制触发bug时这个脚本将运行,保证在归档时必要的bitcode相关文件被拷贝。
This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files are copied when archiving.
 
另外需要注意Carthage 支持OS X的各个版本,但是对于iOS只支持iOS 8及其以上
only officially supports dynamic frameworks. Dynamic frameworks can be used on any version of OS X, but only on iOS 8 or later.
 
最后附上Carthage的github地址:https://github.com/Carthage/Carthage



原标题:Carthage使用(cocoapods的替代)

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

的国际快递:https://www.goluckyvip.com/tag/101110.html
国际快递dl:https://www.goluckyvip.com/tag/101111.html
港鑫汇达国际物流:https://www.goluckyvip.com/tag/101112.html
秘鲁国际物流:https://www.goluckyvip.com/tag/101113.html
国际货运,空运,海运:https://www.goluckyvip.com/tag/101114.html
韩国国际物流韩国货运物流:https://www.goluckyvip.com/tag/101115.html
回乡创业,不知道干什么,能否推荐几个农村老家创业的好项目?:https://www.vstour.cn/a/365177.html
恐怖游轮2002 恐怖游轮2022:https://www.vstour.cn/a/365178.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流