DEV Community

Cover image for How to add a swift package to iOS App using the Swift Package Manager
Maegan Wilson
Maegan Wilson

Posted on • Edited on

How to add a swift package to iOS App using the Swift Package Manager

I'm going to show you how to add a swift package to your iOS app using the Swift Package Manager.

First how to add a package to your app

To add a package you will need a repository’s URL or if the package is hosted on GitHub or GitHub enterprise and you’re logged in you can just search for the package.

There’s actually two ways.

Here is way number 1:

  1. Navigate to the target’s general pane
  2. Click the + button in the Frameworks, Libraries, and Embedded Content
  3. Click on Add Other
  4. Choose Add Package Dependecy

Here is way number 2:

  1. Open the project
  2. Go to the File Menu
  3. Choose Swift Packages and enter the repo URL

How to use the dependency?

To actually use the dependency, you will need to first import the package and then call the property you want.

How to delete a package from your app

  1. Navigate to the swift packages pane in the Project settings
  2. Select the package to delete
  3. Hit the - button

When should you reach for an external dependency?

An external dependency aka package can make your life easier as a developer. Sometimes they can save you hours of coding and figuring out how something works.

I use one in iHog for OSC a network protocol that I have no idea how to actually implement in Swift. OSCKit allowed me to focus on other parts of the app and for the package to actually handle all the OSC communication between the app, the iOS device, and the Hog controller.


If you are finding these posts and videos useful, then please share this post or buy me a coffee.

Buy Me a Coffee Link


Want my posts directly to your inbox?
Great! Sign up here!

Top comments (0)