由于項(xiàng)目是用CocoaPods管理,CocoaPods 1.8將CDN切換為默認(rèn)的spec repo源,并附帶一些增強(qiáng)功能!CDN支持最初是在1.7版本中引入的,最終在1.7.2中完成。 它旨在大大加快初始設(shè)置和依賴性分析。
目前項(xiàng)目使用pods的是1.8.4版本
Ribers-Mac:ZNB_Country2.0 Riber$ pod --version
1.8.4
最近使用pods,卻出現(xiàn)了一下錯誤!
[!] CDN: trunk Repo update failed - 17 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/d/4/CocoaAsyncSocket/0.0.1/CocoaAsyncSocket.podspec.json, error: Operation timed out - SSL_connect
...
按照官方文檔 podfile文件中添加source源:
source 'https://github.com/CocoaPods/Specs.git'
podfile文件中添加source源后,pod install和pod update可以正常操作,但是pod search有些庫卻不正常。
Ribers-Mac:ZNB_Country2.0 Riber$ pod search mj
[!] CDN: trunk Repo update failed - 3 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/0.0.1/MJRefresh.podspec.json, error: Operation timed out - SSL_connect
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/1.4.4/MJRefresh.podspec.json, error: Operation timed out - SSL_connect
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/2.4.9/MJRefresh.podspec.json, error: Operation timed out - SSL_connect
Ribers-Mac:ZNB_Country2.0 Riber$ pod search rbtitle
-> RBTitleView (2.0.1)
簡單實(shí)用的titleView
pod 'RBTitleView', '~> 2.0.1'
- Homepage: https://github.com/RiberWang/RBTitleDemo
- Source: https://github.com/RiberWang/RBTitleDemo.git
- Versions: 2.0.1, 1.0.1, 1.0.0 [master repo]
解決辦法:
1. podfile文件中指定source源為master:
source 'https://github.com/CocoaPods/Specs.git'
2.執(zhí)行pod repo remove trunk移除trunk源
執(zhí)行完后,pod search就都正常了!
Ribers-Mac:ZNB_Country2.0 Riber$ pod repo list
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/Riber/.cocoapods/repos/master
trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/Riber/.cocoapods/repos/trunk
2 repos
Ribers-Mac:ZNB_Country2.0 Riber$ pod repo remove trunk
Removing spec repo `trunk`
注意:podfile文件中一定要指定master源,因?yàn)楝F(xiàn)在默認(rèn)是trunk源
source 'https://github.com/CocoaPods/Specs.git'
參考文章:
- 官方說明(英語不好的同志可在谷歌瀏覽器中打開使用其翻譯功能)
- Github Issules
2021.2.4
pod版本1.10.1
cocoapods 新版1.9 新版的 CocoaPods 不允許用pod repo add直接添加master庫了,可用清華鏡像 repo更新
解決辦法:
- 對于舊版的 CocoaPods 可以使用如下方法使用 tuna 的鏡像:
pod repo remove master // 移除master源
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git // 添加清華源
pod repo update // 更新資源庫
- 新版的 CocoaPods 不允許用pod repo add直接添加master庫了,但是依然可以:
cd ~/.cocoapods/repos // 進(jìn)入pods資源庫
pod repo remove master // 移除master源
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master // 克隆清華源
最后進(jìn)入自己的工程,在自己工程的podFile第一行加上(也可以不加 執(zhí)行pod update操作后 會自動加上):
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'