最近升级Mac系统后使用 pod search
出现错误,内如如下:
coder_zyy@coder_zyydeMacBook-Pro ~ % pod search AFN
[!] CDN: trunk Repo update failed - 4 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/4/e/7/FRDStravaClient/0.0.2/FRDStravaClient.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/4/e/7/FRDStravaClient/0.0.3/FRDStravaClient.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/4/e/7/FRDStravaClient/1.0.0/FRDStravaClient.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/4/e/7/FRDStravaClient/1.0.2/FRDStravaClient.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
按照官方文档在本地 podfile文件中添加source源:
source 'https://github.com/CocoaPods/Specs.git
添加source源后,pod instal
l和pod update
可以正常操作,但是pod search
却不正常
CocoaPods 1.8将CDN切换为默认的spec repo源,并附带一些增强功能!CDN支持最初是在1.7版本中引入的,最终在1.7.2中完成。 旨在大大加快初始设置和依赖性分析。
解决办法:
1.本地 podfile文件中添加source源:
source 'https://github.com/CocoaPods/Specs.git
2.查看本地pod版本并升级
coder_zyy@coder_zyydeMacBook-Pro ~ % pod --version
1.8.4
coder_zyy@coder_zyydeMacBook-Pro ~ % pod repo update
Updating spec repo `aliyun`
Updating spec repo `master`
$ /usr/bin/git -C /Users/coder_zyy/.cocoapods/repos/master fetch origin
--progress
remote: Enumerating objects: 448, done.
remote: Counting objects: 100% (448/448), done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 769 (delta 385), reused 365 (delta 365), pack-reused 321
Receiving objects: 100% (769/769), 90.75 KiB | 225.00 KiB/s, done.
Resolving deltas: 100% (491/491), completed with 202 local objects.
From https://github.com/CocoaPods/Specs
85bd9b0e699..d28452c1911 master -> origin/master
$ /usr/bin/git -C /Users/coder_zyy/.cocoapods/repos/master rev-parse
--abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/coder_zyy/.cocoapods/repos/master reset --hard
origin/master
后面省略...
3.查看本地source列表
coder_zyy@coder_zyydeMacBook-Pro ~ % pod repo list
aliyun
- Type: git (master)
- URL: https://github.com/aliyun/aliyun-specs.git
- Path: /Users/coder_zyy/.cocoapods/repos/aliyun
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/intest_zyy/.cocoapods/repos/master
moduleloveplay
- Type: git (master)
- URL: https://github.com/ModuleLovePlay/PodSpec.git
- Path: /Users/coder_zyy/.cocoapods/repos/moduleloveplay
njhu
- Type: git (master)
- URL: https://github.com/NJHu/NJSpecs.git
- Path: /Users/coder_zyy/.cocoapods/repos/njhu
trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/coder_zyy/.cocoapods/repos/trunk
4 repos
4.执行pod repo remove trunk
移除trunk源
coder_zyy@coder_zyydeMacBook-Pro ~ % pod repo remove trunk
Removing spec repo `trunk`
注意:podfile
文件中一定要指定master
源
因为CocoaPods 1.8版本现在默认是trunk
源。
参考文章:
- 官方说明(在谷歌浏览器中打开可自动翻译为天朝文)
- Github Issules
文中如有总结不对、不到位的地方欢迎指出。谢谢~