skip to Main Content

I recently forked a Swift Package library from GitHub in order to implement a functionality that I’ve been missing. However, when I try to add my version of the package in a Xcode project (by adding the url of my fork), Xcode can’t find any results.

Xcode shows that it found 0 results for my fork

Is this an intended limitation of Swift Package Manager or am I missing something?

3

Answers


  1. Chosen as BEST ANSWER

    I finally worked around this limitation by manually editing both the project.pbxproj and Packages.resolved files, so that they point to the specific commit in the fork of the repository.

    To do this, close Xcode and then open the two files with a plain text editor.

    In the project.pbxproj file, change the url of the repo and the parameters needed to correctly specify the version rule. In my case, I wrote the hash of the commit I needed:

    /* Begin XCRemoteSwiftPackageReference section */
        7902F77227C64GF9001583F1 /* XCRemoteSwiftPackageReference "Cuckoo" */ = {
            isa = XCRemoteSwiftPackageReference;
            repositoryURL = "https://github.com/ajpallares/Cuckoo";
            requirement = {
                kind = revision;
                revision = a9d239ff1bb93fe0204f8285d513f3139b51fbbb;
            };
        };
    

    Do the same for the Packages.resolved file:

    {
      "package": "Cuckoo",
      "repositoryURL": "https://github.com/ajpallares/Cuckoo",
      "state": {
        "branch": null,
        "revision": "a9d239ff1bb93fe0204f8285d513f3139b51fbbb",
        "version": "null"
    }
    

    Obviously, this is not the ideal solution but at least it works ¯(ツ)

    In fact, this seems to be an intended limitation of Swift Package Manager. See:


  2. Try to use http instead of https:
    http instead of https

    EDIT:

    After you tried with http and still have the problem you probably need to create a personal access token:

    1. Go to GitHub and log in.
    2. In the upper right corner you will see your avatar with a button to open a menu. Click and choose Settings.
    3. Choose Developer Settings from the list of settings.
    4. Choose Personal Access Tokens from the list of developer settings.
    5. Click the Generate a personal access token link.
    6. Enter Xcode in the Note text field to let you know the token is for Xcode.
    7. Select the scopes for the access token.
    8. Click the Generate token button.
    9. Copy the token so you can paste it in Xcode.

    Now to use the token in Xcode:

    1. Choose Xcode > Preferences.
    2. Click the Accounts button at the the top of the preferences window.
    3. Click the Add button.
    4. Choose GitHub from the list of accounts.
    5. Click the Continue button.
    6. Enter your GitHub username and personal access token in the text fields.
    7. Click the Sign In button.
    Login or Signup to reply.
  3. In Xcode 14.0.1 started to work by defining commit hash like this:
    enter image description here

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