XCFramework with hidden dependency

Hi everyone!

What I want to achieve

  • ProductSDK — xcframework that will be integrated by clients in their host apps (iOS platform).
  • BusinessLogic — dependency of ProductSDK that shouldn't be exposed to developers integrating ProductSDK

What I tried

  • Added BusinessLogic.xcframework to ProductSDK.
  • Used @_implementationOnly import BusinessLogic to hide BusinessLogic.
  • Then archived and created final ProductSDK.xcframework.


When ProductSDK.xcframework is added to host application, I can import ProductSDK. import BusinessLogic returns no such module, which is expected.
When the app is run, it works on simulator, but it crashes in runtime on real device with an error: "BusinessLogic image cannot be found".


How to add BusinessLogic dependency to ProductSDK xcframework? Is it even possible for iOS platform?

Is BusinessLogic linked dynamically or statically? If it’s the former, this isn’t supported on iOS because iOS does not support nested frameworks. To make this work dynamically you’d have to give your clients two separate XCFrameworks, ProductSDK and BusinessLogic, both of which get added to the app’s top-level Frameworks directory, and that runs counter to your goal of hiding BusinessLogic from your clients.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Thanks for the answer @eskimo. BusinessLogic is a xcframework. Solution to give both frameworks to clients is not possible.
Is it possible to statically link BusinessLogic.xcfamework in ProductSDK, so clients only need to add ProductSDK.xcframework in their app? If it's possible with xcframework, how to do it?

An XCFramework can wrap a framework, a ‘naked’ dynamic library, or a static library. So, if you can build BusinessLogic as a static library and wrap it in an XCFramework, you should be able to statically link it into ProductSDK.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Terms of Service

Privacy Policy

Cookie Policy