http://www.tuicool.com/articles/URjqQvb
http://www.cocoachina.com/bbs/read.php?tid-277900-page-1.html
1.CocoaPods的安装
需要用到ruby,Mac系统自带ruby,但如果不是最新的系统,最好更新一下。
ruby的软件源rubygems.org被墙了,所以先换一下源,命令行下依次执行3条命令
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
然后升级gem
$ sudo gem update --system
完了就开始安装CocoaPods
$ sudo gem install cocoapods
$ pod setup
出现Setting up CocoaPods master repo,半天没有任何反应。原因无他,因为那堵墙阻挡了cocoapods.org。。。
gitcafe和oschina都是国内的服务器,可以用它们CocoaPods索引库的镜像:
$ pod repo remove master
$ pod repo add master https://gitcafe.com/akuandev/Specs.git
$ pod repo update
如果想用oschina的镜像也可以把第二条命令 换成 http://git.oschina.net/akuandev/Specs.git 即可
第二条命令执行的时候会比较耗时,这个时候要去把整个specs仓库clone一下,下载到 ~/.cocoapods里;
cd 到该目录里,用du -sh *命令来查看文件大小,每隔一会看看,最终大小是190多M。
下载某个ios源码后,控制器进入目录执行pod install:
$ pod install Analyzing dependencies [!] The version of CocoaPods used to generate the lockfile (0.39.0) is higher than the version of the current executable (0.35.0). Incompatibility issues may arise.
因此我们需要更新cocoapods,执行下面的命令,但是并没有更新成功。
$ gem update cocoapod
Updating installed gems
Nothing to update
查看当前版本:
$ pod --version
0.35.0
怀疑source地址有变化:
$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
网上查看,告知taobao服务器已经改为https协议,因此执行如下:
$ gem sources -r http://ruby.taobao.org/
http://ruby.taobao.org/ removed from sources
$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
更新系统,提示没有权限:
$ gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.5.1.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
使用sudo来执行操作:
$ sudo gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.5.1.gem (100%)
Successfully installed rubygems-update-2.5.1
Parsing documentation for rubygems-update-2.5.1
执行安装:
$ pod setup
Setting up CocoaPods master repo
Setup completed
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
根据提示执行repo更新:
$ pod repo update --verbose
Updating spec repo `master`
$ /usr/bin/git pull --ff-only
From https://github.com/CocoaPods/Specs
a0baa68..9a14a05 master -> origin/master
error: Your local changes to the following files would be overwritten by merge:
CocoaPods-version.yml
Specs/1PasswordExtension/1.0.0/1PasswordExtension.podspec.json
Specs/1PasswordExtension/1.0.1/1PasswordExtension.podspec.json
Specs/AKUTestKit/1.1.2/AKUTestKit.podspec.json
Specs/ALCore
Aborting
Updating a5c6b67..9a14a05
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
master分支还是失败,查看网上建议,先清除缓存
rm -rf ~/.cocoapods/repos/master
再重新运行:
$ pod setup
Setting up CocoaPods master repo
CocoaPods 1.0.0.beta.2 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Setup completed
最后,到下载的ios工程目录下,执行:
$ pod install
Updating local specs repositories
CocoaPods 1.0.0.beta.2 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.3)
Installing AFOnoResponseSerializer (1.0.0)
Installing DTCoreText (1.6.17)
可见现在问题解决了!