Article

Editing a Package Dependency as a Local Package

Override a package dependency and edit its content by adding a Swift package as a local package.

Overview

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:

  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.

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.

See Also

Local and Standalone Packages

Creating a Standalone Swift Package with Xcode

Bundle executable or shareable code into a standalone Swift package.

Organizing Your Code with Local Packages

Simplify maintenance, promote modularity, and encourage reuse by organizing your app’s code into local Swift packages.

Developing a Swift Package in Tandem with an App

Add your published Swift package as a local package to your app’s project and develop the package and the app in tandem.

class Package

The configuration of a Swift package.