换了台新电脑装Cocoapods可给坑惨了,下载Specs真的是太慢了啊,还容易遇到各种问题,费事又费力,看了一下现在Specs库差不多有100万个文件了,难怪慢啊!!
先安装cocoapods
$ sudo gem install cocoapods
然后在项目的podfile确认一下是不是一个靠谱的源,我一开始的源是 https://github.com/CocoaPods/Specs.git,速度那叫一个慢啊,下的我都要崩溃了,还经常有这个错误
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
这个搜了一下,有很多说法,可能是文件过大,需要增加缓存配置,可能是需要用ssh,也可能仅仅是因为网不好,我是执行了下面这句后重试了几次ok了
git config --global http.postBuffer 1048576000
后来换成了来自清华大学的源,速度舒适。
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
pod file首行添加
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
然后pod install的时候发现刚才下了半天的specs会再下载一遍,让我迷茫的扣了好一会儿头。更要命的是等了好久会报这个错误
[!] Unable to add a source with url `https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git` named `edu-git-cocoapods-specs`.
You can try adding it manually in `/Users/xtuphe/.cocoapods/repos` or via `pod repo add`.
不是说新版本不能用pod repo add这种方式添加了么?
重试了好久后一想既然已经下好了Specs,应该只是没找到,于是我刚才clone到~/.cocoapods/repos下的master文件夹改成了提示的edu-git-cocoapods-specs,然后到项目目录重新
$ pod install

见到了久违的绿字,然后又又又error了,不过这次我已经能确定是网络的问题了,又重试了一次,终于OK
网友评论