Multiple Xcode Targets with same SPM dependency

I have a library added to my project added as a SPM dependeny. My project has multiple targets that the main app is dependent on. However, a target won't compile without linking to the static library. But if mulitple targets need to reference it, it is included in each target giving runtime warnings that it doesn't know which version to use.


Is there a way for multiple targets included in a master target to reference a static package generated by SPM?


The only I can think of is to create a framework target that includes the static package, and then link to that from all the modules. But that defeates the whole idea of SPM generating static libraries.

Replies

Is there a way for multiple targets included in a master target to reference a static package generated by SPM?

I don’t know, alas. You might have more luck asking this over on Swift Forums.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Any luck finding the solution?

Have a look at this stackoverflow post.


https://stackoverflow.com/questions/57625952/consume-swift-package-for-multiple-targets-and-platforms-in-a-project

To add libraries to another targets you need to go to each Target -> General -> Framework, Libraries, and Embedded Content and add them manually.
Add a Comment