Carthage的安装和使用
Carthage和CocoaPods相比,轻量级一些,在swift中使用很方便,它本身就是swift写的。 1.brew安装carthage之前需要安装brew,进入官网(https://brew.sh/index_zh-cn.html) 有详细的安装步骤。 获取 Homebrew打开终端Tterminal`,输入以下命令: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
获取最新版本brew update
其他brew命令brew install git // 使用brew安装软件 brew uninstall wget // 使用brew卸载软件 brew search /wge*/ // 使用brew查询软件,其中/wge*/是个正则表达式,需要包含在/中 brew list // 列出已安装的软件 brew home // 用浏览器打开brew的官方网站 brew info // 显示软件信息 brew deps // 显示包依赖 2.安装Carthage安装brew之后,就可以安装Carthage了。 brew install carthage 安装Carthage之后,查看版本 carthage version // 目前的版本号为0.15.2 3. 使用Carthage进入项目所在文件夹cd ~/路径/项目文件夹
创建一个空的carthage文件touch Cartfile 此时项目文件夹中会有一个名字为Carthage的文件 使用Xcode打开该文件open -a Xcode Cartfile
编辑Cartfilegithub "SVProgressHUD/SVProgressHUD" ~> 1.0
Cartfile格式说明依赖源 Dependency originCarthage支持两种类型的源,一个是
依赖版本号 Dependency Version告诉Carthage使用哪个版本,这是可选的,不写默认使用最新版本
4. 运行Carthage保存并关闭Cartfile文件,回到终端,执行以下命令: carthage update --platform iOS carthage会clone文件中对应的git第三方库,把每一个第三方库编译成二进制文件的framework文件。 其中 当命令执行完毕,在
对于是否把 不要改变 如果其他人想要使用你的工程,你不需要在你的代码中提交已经编译好的framework,他们需要在check out你的工程之后执行
在"Carthage/Build/iOS"文件夹中会生成
Carthage生成目录
*** Skipped downloading Alamofire.framework binary due to the error:
"Bad credentials"
这个错误的原因是carthage通过 解决办法一打开命令行工具
$ git credential-osxkeychain
# 如果出现以下提示说明已经安装,进入第3步
Usage: git credential-osxkeychain <get|store|erase>
# 如果出现以下提示说明未安装,进入第2步
xcode-select: note: no developer tools were found at '/Applications/Xcode.app',requesting install. Choose an option in the dialog to download the command line developer tools.
$ brew install git
$ git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
# 可以进入系统桌面,创建一个临时文件夹,用来clone代码,之后再删除即可
$ cd
$ cd Desktop
$ mkdir tempdir
$ cd tempdir
$ git clone https://github.com/SVProgressHUD/SVProgressHUD.git
解决办法二参考:http://stackoverflow.com/questions/39578496/carthage-error-bad-credentials 5. 添加FrameWorks到项目中点击"项目名称"-> "target" -> "Gerneral",在最底部找到"Linked Frameworks and Libraries"。 打开Carthage文件夹,进入BuildiOS,拖拽SVProgressHUD.framework到Xcode的**Linked Frameworks and Libraries **中。
Link Frameworks
目的是告诉Xcode链接你的app到这个framework,允许你在代码中使用。 下一步选择菜单上的 /usr/local/bin/carthage copy-frameworks
点击 $(SRCROOT)/Carthage/Build/iOS/SVProgressHUD.framework 严格来讲,build phase对项目运行来说不是必须的,但是,这巧妙的解决了APP因为使用的frameworks包含二进制图像的iOS模拟器在提交APP Store时会被自动拒绝的问题。
Run Script
import SVProgressHUD
升级指定Frameworkscarthage update SVProgressHUD --platform iOS 参考参考1:https://github.com/Carthage/Carthage (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |