Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Swift Package Manager error - The repository could not be found

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:

enter image description here

What's especially interesting is that while Xcode claims that the repo is not found, it can discover its version on the previous screen:

enter image description here

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!

like image 384
danqing Avatar asked Nov 12 '19 10:11

danqing


People also ask

How to add Swift package Manager in Xcode?

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.

How do I reset my package cache?

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.

How to add package dependency Xcode?

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.

How do I update Swift package dependencies?

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.


3 Answers

clean DerivedData and add Package again

rm -rf ~/Library/Developer/Xcode/DerivedData/
like image 83
izayl Avatar answered Sep 19 '22 14:09

izayl


When this happened in Xcode 13.3, I just had to trigger the Reset Package Caches action in the Packages menu.

Xcode Reset Package Caches

like image 37
Daniel Saidi Avatar answered Sep 18 '22 14:09

Daniel Saidi


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.

like image 45
Alqueraf Avatar answered Sep 19 '22 14:09

Alqueraf