1.三言兩語闡述下現狀
前因后果暫且不提 ,目前我安裝的cocoapods版本是1.9.1,而且是直接安裝的新版本,所以
.cocoapods/repos/
下只有一個trunk,沒有master等其他文件夾。
cocoapods1.8會后CDN被作為spec的默認倉庫來源,好處的話第一次安裝的時間大幅縮短,不用從https://github.com/CocoaPods/Specs.git
上拉取整個倉庫代碼,后面用到的時候也只會拉取當前所需。
說起來也是沒辦法,降級回去安裝的時候pod setup
下載又卡住,安裝不成,只能重新換回1.9繼續搞。
2.主要問題及解決辦法
2.1 RPC failed
2.1.1 問題描述
RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
2.1.2解決辦法
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
或者使用別的源
https://gitclub.cn/CocoaPods/Specs.git
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
2.2 trunk連接問題
2.2.1問題描述
[!] CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/ Response: 400
或
[!] CDN: trunk Repo update failed - 70 error(s): CDN: trunk URL couldn't be downloaded: [庫信息], error: Failed to open TCP connection to raw.githubusercontent.com:443
或
[!] CDN: trunk Repo update failed - 14 error(s): CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/[庫路徑].podspec.json Response: Couldn't connect to server
2.2.2解決辦法
解決思路有兩條,一條是退回舊方式,另一條是使用新方式,其中退回舊方式又分為兩種。
2.2.2.1 退回舊方式1 - 回退cocoapods版本
1.查看gem本地安裝的cocoapods版本
gem list
2.刪除cocoapods和cocoapods-core程序包
sudo gem uninstall cocoapods -v版本號
sudo gem uninstall cocoapods-core -v版本號
3.安裝其他版本cocoapods
sudo gem install cocoapods -v版本號
2.2.2.2 退回舊方式2 - 指定source源
1.podfile文件中制定source源為master。
source 'https://github.com/CocoaPods/Specs.git'
2.移除trunk源。
執行pod repo remove trunk
2.2.2.3 使用新特性,解決DNS污染問題
1.編輯Podfile,將CDN設置為主要來源,
1.8+
是默認項
source 'https://cdn.cocoapods.org/'
2.有master的可以移除master了
pod repo remove master
3.獲得raw.githubusercontent.com的真實ip地址
可以使用nslookup raw.githubusercontent.com
獲取
也可以使用https://www.ipaddress.com或https://site.ip138.com/raw.githubusercontent.com/輸入raw.githubusercontent.com
查詢ip地址。
4.修改hosts
終端輸入sudo vi /etc/hosts
輸入i
進入編輯模式
在最后一行添加151.101.76.133 raw.githubusercontent.com
其中151.101.76.133
是上一步中獲取的ip地址
control+c
退出編輯
輸入:wq!
保存退出
5.重試下就可以了
不行的話可以刷新下DNS緩存sudo killall -HUP mDNSResponder