Logo for tanaschita.com

How to add local Swift Packages to an iOS project

Learn how to add local dependencies to your iOS project by using Swift Package Manager and Xcode

17 Apr 2021 · 2 min read

The Swift Package Manager not only allows adding remote libraries as Swift Packages, but also local Swift Packages.

This possibility is useful, for example, when splitting a project into multiple libraries without having to worry about versioning and being able to directly edit the code.

This tip is a quick start for adding local Swift Packages to an iOS project. For more in-depth concepts, check out this Guide on the Swift Package Manager for iOS.

Adding a local Swift Package to an iOS project

Basically, adding a local Swift Package requires two steps.

  1. Drag and drop the local package into the Xcode project or workspace.
  2. Add it to the Frameworks, Libraries, and Embedded Content section in app targets general pane.
Adding local Swift Packages
Adding local Swift Packages

After doing that, we can import our local packages into our Swift files as we would do with any other library.

Using local Swift Packages in an iOS project
Using local Swift Packages in an iOS project

Removing a local Swift Package

Removing a local Swift Package from the project works the same as removing any other file from the project.

Related tags

Written by

Articles with related topics