Search code examples
xcode-mergeable-libraries

How do I define and use a merged framework?


I am experimenting with the Mergeable Libraries feature introduced in Xcode 15.

I have two existing dynamic frameworks which I've marked as mergeable libraries, i.e. I've set the MERGEABLE_LIBRARY build setting of these two frameworks to YES. Let's call these two frameworks MergeableFramework1 and MergeableFramework2.

I've created a new dynamic framework which (1) links to MergeableFramework1 and MergeableFramework2 and (2) has a MERGED_BINARY_TYPE build setting value of manual. Let's call this framework MergedFramework.

I've created an app which links to MergedFramework. I can import the MergedFramework module in the app's source files and the app builds fine. However, when I try to use any of the classes defined in MergeableFramework1 or MergeableFramework2, I get a build error telling me that the class cannot be found.

What am I doing wrong here? How do I define and use a merged library?


Solution

  • I spotted my error thanks to a colleague.

    I need to continue linking the app to MergedFramework as I'm doing. However, in the app's source files, I need to import MergeableFramework1 and MergeableFramework2 as needed and not MergedFramework 🤦‍♂️

    Addendum

    I've learnt since posting my question that I don't need to change the MERGEABLE_LIBRARY build setting of MergeableFramework1 and MergeableFramework2 to YES. It's enough just to set the MERGED_BINARY_TYPE build setting of MergedFramework to automatic.