成功安装 CocoaPods 1.9.1 版本后,执行 pod install,遇到错误:

[!] CDN: trunk Repo update failed - 35 error(s):

CocoaPods Error (CDN trunk Repo update failed)

原因:CocoaPods 1.9 将 CDN 切换为默认的spec repo源,并附带了一些增强功能!CDN支持首先在1.7版本中引入,并在1.7.2中最终确定。它旨在显著加快初始设置和依赖性分析。使用1.9,CocoaPods 不再需要克隆现在庞大的master specs repo才能正常工作,用户几乎可以立即将他们的项目与CocoaPods集成。

The CocoaPods Master Repo

可以查看源列表:

pod repo list

pod repo list

去目录 ~/.cocoapods/repos 看一下,还真是,以前只有 https://github.com/CocoaPods/Specs.git 资源的:

CocoaPods-Specs-git

现在多了个 trunk 源:

CocoaPods-trunk-git

(而且我的只发现 trunk 源,看来得下载庞大的 https://github.com/CocoaPods/Specs.git 源 !!!)

Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`

我这速度很挺快的。。。

CocoaPods-Specs-git-Downloading

。。。

。。。

花了很长时间,终于下载好了。。。

cocoapods DIR

。。。

。。。

。。。

上述的错误解决办法是:

方法一:podfile 文件中指定 source 源为 master ,因为现在默认是 trunk 源。

在 Podfile 加上 https://github.com/CocoaPods/Specs.git

Admins-iMac:~ admin$ pod repo list

master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/admin/.cocoapods/repos/master

trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/admin/.cocoapods/repos/trunk

2 repos

倘若解决不了,使用方法二:移除 trunk 源

pod repo remove trunk

图?

如果你是新安装 CocoaPods,跟我的一样,上面的两个办法都会下载庞大的 https://github.com/CocoaPods/Specs.git 源。

如果你是从 CocoaPods 低版本升级过来了,只需要移除 trunk 源就可以了。

 

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐