Sharing swift package dependencies between multiple projects/frameworks?

Heya'lls! Been looking around the internet but I simply could not find an answer or maybe I was wording my question wrong.

My team is pretty new to SPM and we've decided to move some of our dependencies to it. The only problem is that we have multiple frameworks/libraries in our workspace depending on the same 3rd parties and it seems that we are only allowed to add a package in one project else Xcode starts pumping some duplicate symbols errors.

Would be awesome if you could help us figure this out :slight_smile: Thanks!

2 Likes

Package targets are statically linked by default. If you use a static library from both a dynamic framework and an application, it will end up embedded separately into each.

You can work around it by creating an intermediate .dynamic package (or Xcode framework) that merely declares all the dependencies and contains no code (except @_exported import Whatever if you want). It will end up with the entire package graph statically embedded in it. Then any number of other targets can dynamically link that intermediate library instead, and safely be able to import whatever they need from underneath.

1 Like

Thanks for the suggestion! So I created a framework where I placed the SPM dependencies and had it linked to the rest of my static libraries & main project.

I'm having the exact same problem, but when I import my framework that does:
@_exported import Firebase
I get "Missing required module Firebase".
Is there anything else you had to do ?

Terms of Service

Privacy Policy

Cookie Policy