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

I'm building an app with capacitor for ios. When I launch the command 'npx cap sync ios' (which launch pod install) and I get this error :

✖ 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`.

If i execute the recommandation :

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

I get this error

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

I'm blocked on this issue since 6 hours. I read all post mentionning this error on internet.



Solution 1:[1]

Temporary solution :

I added `source 'https://github.com/CocoaPods/Specs.git' on the top of my Podfile

platform :ios, '11.0'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
....

But it takes 30 minutes to download all the repo (2.5gb) in my Users/damien/.cocoapods/repos/ folder ?

Solution 2:[2]

You can restore trunk using:

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

found at: https://github.com/CocoaPods/CocoaPods/issues/10078#issuecomment-696481185

Solution 3:[3]

Another way you can get it working locally since this CDN is an issue

pod repo remove trunk

In Podfile

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

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

found at:https://github.com/CocoaPods/CocoaPods/issues/10078

Solution 4:[4]

I got it fixed according to what Logan says on Github:

gem uninstall cocoapods
gem install cocoapods -v 1.8
pod install

It seems that there's a bug or something with 1.9.1!

Solution 5:[5]

If you still have issues after changing the source in your Podfile:

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

Its because you need to remove the current "trunk" and re-install pods with --repo-update:

pod repo remove trunk
pod install --repo-update  

OR --clean-install to execute a full pod installation ignoring the content of the project cache:

pod install --clean-install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Damien Romito
Solution 2 Apan
Solution 3
Solution 4 Ali
Solution 5 Sayuri Mizuguchi