Modifying a Dependency

How to edit a Dependent Package?

Well, it turns out this could be the easiest thing in development.

When you have a library that your code depends upon - generally Xcode does allow you to see the code - but it is Read-Only - you cannot edit the code. This makes a lot of sense. But what if you are bowering an API library and want/need to change or update it a bit. Then you are going to want to edit the source code for the library. So you need to set it up as a LOCAL dependency.
Apple recommends you leave the dependent library in your project. And somehow the compiler build system is going to learn to ignore that dependency and pay attention to your newly additional LOCAL (editable) package. Apple has a great section in the Docs (see below) about doing this. I'm about to test this all out.


Caveat: I can mess this up!

Just when you think it couldn't get easier... there is a way to mess this up.

I assumed the folder names would not matter. But I appear to be very wrong.

Pay attention to the folder names - they need to match, so that Xcode overrides the dependent Library with the Local Package (that is now editable).

Reference:

Editing a package dependency as a local package | Apple Developer Documentation

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.