Carthage类似于Cocoapods
1.安装brew
/usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.安装Carthage
brew install carthage
3.使用
1)使用Xcode创建工程cathage_demo
2)cd /Users/lichanglai/Desktop/cathage_demo
3)touch Cartfile
open -a Xcode Cartfile
4)修改Cartfile
1).使用远程资源git://, http://, ssh://
git "https://git.corpautohome.com/GP_APPMAIN_IOS_ARCH/AFNetworking.git" "7bc7fbdaac90844626aabc61842b6072e9edeeec"
2).使用本地路径
git "file:///Users/lichanglai/Desktop/ThirdControl/AsyncSocket" == 0.1.5
3).使用github
github "SDWebImage/SDWebImage"
可以指定分支/标签/提交. 不可混用
如
分支 git "file:///Users/lichanglai/Desktop/ThirdControl/SDWebImage" “dev”
标签 git "file:///Users/lichanglai/Desktop/ThirdControl/AsyncSocket" == 0.1.5
提交 git "file:///Users/lichanglai/Desktop/ThirdControl/SDWebImage" “84f67b127af44dd5b6db9e7f02ea42cc58fa44b8"
![](https://img.haomeiwen.com/i2381613/2b6581c874736654.png)
5)carthage update --platform iOS
6)添加frameWork
![](https://img.haomeiwen.com/i2381613/cfad2b2215d1d603.png)
7)添加脚本
![](https://img.haomeiwen.com/i2381613/615c03a12401510f.png)
8)使用
![](https://img.haomeiwen.com/i2381613/a2a64b66b6dafb14.png)
使用过程中遇到run问题
unable to find utility "xcodebuild", not a developer tool or in PATH
选择Command Line Tools:
![](https://img.haomeiwen.com/i2381613/0e97e0abcef8c3e2.png)
可以使用本地资源引入
git "file:///Users/lichanglai/Desktop/AFNetworking" == 3.1.0
若是Cartfile使用https的方式引入
git "https://git.corpautohome.com/ThirdControl.git"
则会遇到验证用户名密码问题
可通过全局的credential.helper的配置来使用osxkeychain helper解决
1)$ git credential-osxkeychain
# 如果出现以下提示说明已经安装
Usage: git credential-osxkeychain
2)$ git config --global credential.helper osxkeychain
3)$cd /Users/lichanglai/Desktop
$ mkdir tempdir
$cd tempdir
$ gitclonehttps://github.com/SVProgressHUD/SVProgressHUD.git
输入用户名,密码
再次进入项目所在目录,执行carthage update命令,就可以看到问题解决了
网友评论