When I want to make changes to a Swift package, I find it useful to do it in the context of a project that depends on that package. Unfortunately, you can't directly edit a Swift package you add as a dependency to an Xcode project. It's read-only and managed by Xcode. What you can do is add a local copy of the package that overrides the package dependency.
Swift Package Dependencies
I previously covered creating Swift packages in Xcode 11 and then adding them as a dependency to a project. Xcode downloads the package files from the remote repository:
You can browse the source files in the package, but you cannot edit them in Xcode (which is probably for the best).
Editing A Standalone Package
You always have the option to clone the package repository to a new folder:
$ git clone <URL of Git repository>
You can then open the
Package.swift file in Xcode and work on the package directly:
After you've made your changes, commit the package back to the remote repository.
This is cumbersome if you want to try your updated package with an existing Xcode project. To get Xcode to download the updates from the remote repository you either need to tag the commit with a new version or change the project dependencies to refer to the specific commit:
Luckily, there's a better way.
Editing A Local Copy
Clone the package repository to a local directory as before.
Drag the whole folder into the Xcode project that has a dependency on the package:
Xcode overrides the package dependency with the same name as the local package. Notice in the screenshot how the Swift Package dependency disappears from the file navigator.
Make your changes to the local package and test them with the project before pushing the changes to the remote repository.
Release the changes by tagging the commit and then pushing the tag:
To switch back to using the remote package:
Delete the local copy of the package from the project.
Make Xcode update the package dependencies
File > Swift Packages > Update To Latest Package Versions.
You should now see the latest version of the remote package in the file navigator: