Consume Swift Package for multiple targets and platforms in a project? Consume Swift Package for multiple targets and platforms in a project? swift swift

Consume Swift Package for multiple targets and platforms in a project?


I had the same problem, and I only found this two solutions:

First, add the package to the first target:

Add package

Then, the first option is going to the other target, General tab, and in Frameworks, Libraries and Embedded Content press +, select the package and press Add:

Adding package in General tab

The other option is going to build Phases and repeat a similar way in Link Binary With Libraries:

Build Phases

Select package

At the moment, I only know this options, I hope in the future Apple could improve this with a multi-check, for example.


In addition to the solution diego-carrera gave I had to reset the swift package caches to have the package available for all targets in the framework dialog.

In Xcode: File -> Swift Packages -> Reset Package Caches


If you add a new target after you added the dependency, then you will have to remove the dependency from the project and then add it back in again. Otherwise the library will not show up in the framework chooser.

It's annoying that the one reliable thing Xcode can do with Swift Package Manager is crash for me. So make sure you have a backup of the project because it can get to a state that just opening it will crash Xcode.