skip to Main Content

enter image description here

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.

enter image description here

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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:

    1. Up to Next Major Version: Useful for getting the latest major stable release.
    2. Up to Next Minor Version: Useful for getting the very latest releases.
    3. Range of Versions: Useful for resolving dependencies specific to a particular dependency chain (careful configuration).
    4. Exact Version: Useful for pinning a version to a particular working release, or fork.
    5. Commit: Useful for pinning a Package to a commit rather than a release version.

    Xcode SPM "Add Package" prompt

    Xcode Add Package prompt

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search