skip to Main Content

I recently added some Swift Packages to my Xcode 11.3 project manually by dropping them onto the Project Navigator. This allows me to edit out some errors in the source.

Manually added packages in Organizer

By doing this, Xcode automatically adds these to Source Control.

Packages automatically added to Source Control

I can’t seem to find any way to remove them from Source Control from within Xcode. I would prefer to retain these as dependencies but commit them to my own source control and ignore master/remote.

Fetch and Refresh Status from Git yields:

Repos Locked

This behaviour is instructed by Apple here: Editing a Package Dependency as a Local Package

To add the Swift package as local package to your project:

  1. Check out your package dependency’s source code from its Git
    repository.

  2. Open your app’s Xcode project or workspace.

  3. Select the Swift package’s folder in Finder and drag it into the
    Project navigator. This action adds your dependency’s Swift package as
    a local package to your project.

  4. Make changes to the local package and your app, then verify them by
    building and running your app.

  5. When you’re done editing the local package, push your changes to its
    remote Git repository.

  6. When the changes have made it into the package’s next release, remove
    the local package from your project, and update the package dependency
    to the new version.

Step 5 here is broken. I don’t have write access to that repo.

Other things I tried.

I’ve tried deleting Clean, Rebuild and deleting Derived Data

I’ve tried this SO answer however Blueprint.xcscmblueprint doesn’t exist.

2

Answers


  1. The problem you seem to be trying to solve is: You want to make changes to package source files in a maintainable way, and these are not your packages.

    Clearly, of itself, that is a complete non-starter. These files don’t belong to you, in any sense whatever. And as soon as a new version comes down from the remote repo, your changes will be overwritten anyway.

    This sort of thing is always an issue when you rely on third-party code, especially in a dependency architecture like pods or packages. If there’s a problem with the code, you can’t fix it; it isn’t your code.

    One option is to create an Issue at GitHub and try to get the owners of the code to fix whatever the problem is.

    Another possibility is to try to write "shim" code in your code, such as to fix whatever the issue is by plastering it over somehow.

    Alternatively, since this package repo is presumably at GitHub, you can fork the repo. Now it is your package, and you can set up a dependency on that and make changes and push them up to your fork. Of course, the original ("upstream") repo may change, but then you will reconcile those changes with yours as a separate operation.

    Still another possibility, of course, is to abandon the notion of package management and dependency entirely and just incorporate the desired source files directly into your project. Now they are yours and you can do with them what you like. (Be careful of copyright issues, of course. You may still have to give credit where credit is due.)

    Login or Signup to reply.
  2. Download the third party library once. Make your changes. Create a patch file. Put the patch file in your source code control. This is followed by lots of manual work when yo want to switch to a different version of the third party library.

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