← Articles

Managing package dependencies with Swift Package Manager in Xcode

Updated in

Adding a Package dependency

In Xcode, go to FileAdd Package Dependencies... OR select your project in the Project Editor, go to the Package Dependencies tab, and press the + (plus).

Enter a Package URL (e.g. a GitHub repository URL) or a search term in the search field in the upper right.

Adding a package dependency in Xcode

Select the package you want to add.

Select a Dependency Rule. In most cases, you probably want to set this to Up to Next Major Version.

Click Add Package.

Under Add to Target, select the target you want to add the package to. (Want to add to multiple targets? See below.)

Done! 🚀 Yes, it's that simple.

Adding a package dependency to multiple targets

Select the additional target you want to add your package to in the Project Editor.

In the General tab, scroll down to Frameworks, Libraries, and Embedded Content.

'General' tab for selected target in Xcode

Click the + (plus), select your package in the list, and click Add.

Package selection window in Xcode

Updating a package Dependency

Find your package under Package Dependencies in the Project Navigator

Right-click the package and select Update Package.

Right-click options for package dependency in Xcode

You can also update all package dependencies to their latest versions by right-clicking Package Dependencies and selecting Update to Latest Package Versions OR by going to FilePackagesUpdate to Latest Package Versions.

Removing a package dependency

Select your project in the Project Editor.

In the Package Dependencies tab, select the package you want to remove.

Click the − (minus) and then Remove.

'Package Dependencies' tab for selected project in Xcode


— Alex