1

I've built swift frameworks before, but I've never dealt with one that has 3rd party dependencies.

What I have right now is a Swift framework that has a dependency on several Swift packages. When I build it I see MyFramework.framework in the products folder as well as bunch of dependencies. I can make XCFramework out of it, but when integrating (embedding) it into another app I see an error that MyFramework is missing its dependencies (see image below).

enter image description here

What am I doing wrong or missing?

Eugene Gordin
  • 4,047
  • 3
  • 47
  • 80

1 Answers1

2

Creating a framework (or xcframework) that has embedded other frameworks is not supported for iOS(I believe this is answered here). But there is an other way. You can statically link all the dependencies of your library, so in the final framework the binary will also contain the code of its dependencies.

If you are using CocoaPods and the name of the framework is aFramework you can do:

  target 'aFramework' do
    pod 'Alamofire', :linkage => :static
  end

Then you can use the created aFramework.framework in a application target that does not have the Alamofire framework, since the code will be "embedded" in the aFramework's binary.

Christos Koninis
  • 1,499
  • 1
  • 15
  • 28