I can't find any SO questions regarding this, but I've run into this problem twice. Basically when I'm trying to add a new package via SPM, I sometimes get the following error:
The repository could not be found. Make sure a valid repository exists at the specified location and try again.
For example, I'm trying to get PanModal (https://github.com/slackhq/PanModal) and I get the following:
What's especially interesting is that while Xcode claims that the repo is not found, it can discover its version on the previous screen:
What can be wrong here? Arguably PanModal just got SPM support, but that's 15 hours ago and I think that should be enough. Also iiuc SPM is decentralized so there shouldn't be cache or registry stuff that's in the way?
Thank you!
Open your Xcode project, navigate the File tab within the macOS bar, and click on “Add Packages”. In the Add New Package window, you can select from recently used or Apple Swift Packages. Alternatively, you can search for a package via the name or the URL to the Github page.
Resetting the Xcode Package Cache: To reset the package cache, open the File menu, navigate to Packages, and click Reset Package Caches. This will delete all local package data and redownload each package from its source online.
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.
To resolve, Open the project from the project panel, select the project (not the targets), then select the "Swift Packages" tab. Double click on the package you want to update and change the minimum version to the next major version. Save this answer. Show activity on this post.
clean DerivedData and add Package again
rm -rf ~/Library/Developer/Xcode/DerivedData/
When this happened in Xcode 13.3, I just had to trigger the Reset Package Caches action in the Packages menu.
I had to disable HTTPS to SSH rewriting for Git.
Check inside your ~/.gitconfig
file if you have some line such as:
[url "[email protected]:"]
insteadOf = https://github.com/
If so comment it or remove when adding Swift Package Manager dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With