pod setup之前的步骤我这里就不说了,你们看这个博客就是:
http://blog.devtang.com/2014/05/25/use-cocoapod-to-manage-ios-lib-dependency/
为什么要执行pod setup?
所有的项目的 Podspec 文件都托管在https://github.com/CocoaPods/Specs。第一次执行pod setup时,CocoaPods 会将这些podspec索引文件更新到本地的~/.cocoapods/目录下,这个索引文件比较大,有 300多M 左右,在执行一次pod install之后会增加到700多M。所以第一次更新时非常慢。
如何查看执行pod setup的进度?
执行pod setup会输出Setting up CocoaPods master repo
之后就不动了,其实不是没动,是动的很慢。
你可以执行:cd ~
执行:ls -a
执行:cd .cocoapods
执行查看.cocoapods文件的大小命令:du -sh *
会输出:56K repos
每隔几分钟后查看会发现大小在发生变化,但是非常非常慢。
本人因为是下午6多开始安装cocoapods的,一直搞到凌晨1点多都没有安装成功。
开始步入正题,如何解决pod setup 的慢?
使用 CocoaPods 的镜像索引
一个叫akinliu的朋友在gitcafe和oschina上建立了 CocoaPods 索引库的镜像,因为 gitcafe 和 oschina 都是国内的服务器,所以在执行索引更新操作时,会快很多。如下操作可以将 CocoaPods 设置成使用 gitcafe 镜像:
先执行:pod repo remove master
执行:pod repo add master https://gitcafe.com/akuandev/Specs.git

上面命令若输出结果类似下图,则表示执行成功了
执行:pod repo update
输出类似下图,则表示执行成功了

将以上代码中的https://gitcafe.com/akuandev/Specs.git替换成http://git.oschina.net/akuandev/Specs.git即可使用 oschina 上的镜像。
上面都执行成功了,那么恭喜你安装CocoaPods成功了。
如何使用CocoaPods,请看我的下一篇文章。
本人第一次发布文章,请多多指教,欢迎评论。
转载请注明来源,谢谢!!!
网友评论
只需要把索引clone到本地对应的文件夹就可以了
给个链接:http://www.jianshu.com/p/82a6d6c7b000
然后就是以下步骤:
1.pod repo remove master
2.pod repo add master https://gitcafe.com/akuandev/Specs.git
//会出现[!] To setup the master specs repo, please run `pod setup`.不管它,继续。
3.git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
//3步需要等三两分钟才开始下载,然后就是坐等十来分钟下载时间。
4.pod repo update
//到这结束前后大概20来分钟,试一下:pod search masonry
//再次感谢教程。
Updating spec repo `danylokostyshyn`
$ /usr/bin/git pull --ff-only
Already up-to-date.
Updating spec repo `master`
$ /usr/bin/git pull --ff-only
卡到这里不动了
pod repo add master https://gitcafe.com/akuandev/Specs.git
这句会报[!] To setup the master specs repo, please run `pod setup`的错,看你图片上你是重新执行了:
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
最后pod update,漏掉了上面那句,导致第一次看没有看评论之前一头雾水额
楼主截图也不清楚。水到家。最后还是自己search了一下 才知道安装成功了
1. git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
2. pod setup