Tuesday, 26 June 2018

Build Swift dynamic framework with third party static framework as a single framework

Trying to prepare a single dynamic framework to my customer. My framework (A.framework) uses third-party recognition static framework (B.framework). I can't provide separate A and B frameworks to the customer. Ideally B.framework should be built and included into my A.framework's binary, so the customer's app will only embed A.framework without any additional actions to link with that third-party app.

What I did:

  1. Added B.framework to the project.
  2. Added B.framework to "Linked Frameworks and Libraries" in the corresponding target.
  3. Built A.framework.
  4. Created a demo application and included A.framework to the project.
  5. Added A.framework to "Embedded Binaries".
  6. Demo app's build fails with message "Missing required module 'B'" (despite the fact that it is used in A.framework only).

Note:

  • I neither created any modulemap files for B.framework, nor additional run scripts
  • Making A.framework static is not acceptable because it includes some resources (storyboards, icons and some other files)
  • Tried to make un-recommended "umbrella" framework but got stuck on loading B.framework's bundle in demo app
  • Tried to make fake "umbrella" framework by simply copying B.framework inside A.framework, but got 2 problems - huge size of A.framework and Mach-O error while exporting the demo application (because of Mach-O difference between dynamic A and static B frameworks)

Any ideas would be highly appreciated!

UPD 1: This is not about umbrella framework because the proper umbrella framework implementation requires to load sub-framework from bundle which is not good. The fake framework implementation (sub-framework simply copied to umbrella) won't work for release because of different Mach-O values - dynamic and static. Plus fake umbrella framework has a huge size because sub-framework is being fully copied inside umbrella.

UPD 2: Created a small test project: StaticFrameworkTest which has 3 sub-projects:

  1. Demo-application with dynamic framework dependency (framework A) and shouldn't know anything about framework B
  2. Dynamic framework with static framework dependency (framework B) which ideally should be included in A framework's binary.
  3. Static framework B


from Build Swift dynamic framework with third party static framework as a single framework

No comments:

Post a Comment