Using separate device and simulator frameworks

We're incorporating a third-party framework into our iOS app. It is provided to us as two separate frameworks, one with arm64 code (for devices), and one with x86 code (for the simulator).


How do I include these frameworks in my iOS Xcode project such that if I target the simulator, the simulator version of the framework gets linked and embedded, and if I target a dervice, the device version gets linked and embedded?


Most people online try to make a "fat" Framework, but as I understand it, cross-platform Frameworks have never been supported by Xcode.


How does Xcode handle this with the OS Frameworks? I guess you never have to embed those, but I do nee to embed my framework.


Thanks.

Replies

1. If you have access to the source code of the framework, may be via pods, then there is nothing to worry about.

2. If these are two seperate binaries then project setup becomes tricky a separate target one each for the arm & x64 binary image, lib or framework.

3. Who ever told you that fat libraries were never supported by Xcode with respect to arm & x64 images combined into one library is probably someone you shouldn't be listening to ...

The easiest way is to use an xcconfig file. Setting one of those up for your project / target is out of scope but once you do:


This will link your framework. By default it will select MyFramework_ARM but on Simulator builds it will select MyFramework_Sim.


OTHER_LD_FLAGS = $(inherited) -Wl,MyFramework_ARM
OTHER_LD_FLAGS[sdk=embeddedsimulator*] = $(inherited) -Wl,MyFramework_Sim



The other way to do this is with a duplicate target: one for device and one for Simulator but that is much more complicated to maintain.

Any details about the item 1. i.e. using pods to solve this issue?