'Swift Package Manager could not be resolved all libraries, project
This error always happens whenever I add a new Package via Swift Package Manager in Xcode:
Cannot fetch library
I've already configured my GitHub Auth Token setting in Xcode and registered my GitHub account.
My macOS version is Monterey 12.1, my Xcode version is 13.1, my command-line tools are 13.1, and I'm using an M1 chipset Mac.
Solution 1:[1]
Configure Dependency Rule ?
tl;dr
I encountered this issue today and managed to resolve the Package by changing the Dependency Rule from Branch -> master
to Up to Next Major Version and checking their latest Release versions from GitHub.
Other Dependency Rules
We can also try changing from Branch to other rules depending on our application:
- Up to Next Major Version: Useful for getting the latest major stable release.
- Up to Next Minor Version: Useful for getting the very latest releases.
- Range of Versions: Useful for resolving dependencies specific to a particular dependency chain (careful configuration).
- Exact Version: Useful for pinning a version to a particular working release, or fork.
- Commit: Useful for pinning a Package to a commit rather than a release version.
Xcode SPM "Add Package" prompt
Solution 2:[2]
I tried to simulate your problem, Xcode and command-line version are the same. I was able to add SnapKit into my project without problems. Try this workaround:
Project -> Package Dependencies -> + -> paste the link: https://github.com/SnapKit/SnapKit -> Dependency rule set to Up To Next Major -> Add Package.
It should add a new package. Currently in version 5.0.1 If you have still a problem, just click Add Anyway, build the project and send a screenshot of the error.
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 | Pranav Kasetti |
Solution 2 | Juraj Macák |