Override a package dependency and edit its content by adding a Swift package as a local package.
- Swift Package Manager
When you’re using an open-source Swift package from the open-source community in your app as a package dependency, you may want to make edits to it. For example, you may want to contribute a fix for a bug. However, you can’t directly edit the content of a package dependency. To make changes to it, you need to add the Swift package as a local package to your app’s project. Don’t remove your package dependency; adding a local package overrides the package dependency with the same name. Xcode will use the package dependency again when you remove the local package from your project.
To add the Swift package as local package:
Check out your package dependency’s source code from its Git repository.
Open your app’s Xcode project or workspace.
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.
Make changes to the local package and your app, and verify them by building and running your app. When you’re done editing the local package, push your changes to its remote Git repository. When the changes have made it into the next release of the Swift package, remove your local package, and update the package dependency to the new version.