我们在安装cocoapods时,pod setup时出错
错误情况一:
$ pod setup
Setting up CocoaPods master repo
[!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git) master
Cloning into ‘master’…
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
错误情况二:
$ pod setup
Setting up CocoaPods master repo
[!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git) master
Cloning into ‘master’…
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我们知道pod setup这一步等待的时间非常漫长,有可能等了几个小时最终却失败,不得不查找解决办法重来。
以上两个错误的解决办法
1. 检查版本更新
$ sudo gem update --system
2.卸载老的cocoapods
$ sudo gem uninstall cocoapods
卸载完之后,终端会出现以下内容
Select gem to uninstall:
1. cocoapods-1.3.1
2. cocoapods-1.4.0.beta.2
3. cocoapods-1.5.0
4. All versions
>
终端帮你列举出了所有的cocoapods版本,你在末尾的“>”后面直接输入对应的序号,就是卸载序号对应的版本,例如输入1,就是卸载cocoapods-1.3.1,输入4,就是卸载所有版本,这里你直接输入4即可。
3.重装
$ sudo gem install -n /usr/local/bin cocoapods --pre
如果你的mac系统是10.11之前,则输入“sudo gem install cocoapods”
4.终端输入如下2条指令
$ sudo chmod +rx /usr/local/bin
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
注意:上面的第2条指令中,-switch后面的路径有些人可能不同,你直接从你的应用程序里,将Xcode子文件中的Developer直接拖到终端即可
5. pod setup
$ pod setup
成功之后,终端出现如下内容