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.
2
Answers
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.
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:
Xcode SPM "Add Package" prompt