无法添加带有 url `https://cdn.cocoapods.org/` 名为 `trunk` 的来源

Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk`

我正在为 ios 构建一个带有电容器的应用程序。当我启动命令时 'npx cap sync ios' (启动 pod install)并且出现此错误:

✖ Updating iOS native dependencies with "pod install" (may take several minutes): 
✖ update ios: 
[error] Error running update: Analyzing dependencies
Cloning spec repo `trunk` from `https://cdn.cocoapods.org/`
[!] Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk`.
You can try adding it manually in `/Users/damien/.cocoapods/repos` or via `pod repo add`.

如果我执行建议:

pod repo add trunk https://cdn.cocoapods.org/

我收到这个错误

[!] Repo name `trunk` is reserved for CocoaPods' main spec repo accessed via CDN.

我在这个问题上被封锁了 6 个小时。我在互联网上阅读了所有 post 提及此错误的内容。

临时解决方案:

我在我的 Podfile

顶部添加了 `source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
....

但是下载我的 Users/damien/.cocoapods/repos/ 文件夹中的所有 repo (2.5gb) 需要 30 分钟

您可以使用以下方法恢复 trunk

pod repo add-cdn trunk https://cdn.cocoapods.org/

发现于:https://github.com/CocoaPods/CocoaPods/issues/10078#issuecomment-696481185

由于此 CDN 存在问题,您可以通过另一种方式使其在本地运行

pod repo remove trunk

在 Pod 文件中

source 'https://github.com/CocoaPods/Specs.git'

# source 'https://cdn.cocoapods.org/'

发现于:https://github.com/CocoaPods/CocoaPods/issues/10078

我根据what Logan says on Github修复了它:

gem uninstall cocoapods
gem install cocoapods -v 1.8
pod install

1.9.1 好像有 bug 什么的!

如果在 Podfile 中更改源后仍然有问题:

source 'https://github.com/CocoaPods/Specs.git'

这是因为您需要删除当前的“trunk”和 re-install pods with --repo-update:

pod repo remove trunk
pod install --repo-update  

--clean-install 执行完整的 pod 安装而忽略项目缓存的内容:

pod install --clean-install