How to conditionally link an xcframework?

Hi all,

I have an xcframework for iOS that only contains an arm64 framework, not a simulator framework. When run on the simulator, no code from the framework is needed (it is stubbed/mocked out).

However, I'm struggling to find how to link the xcframework only for device builds.

So the situation is this:

If I link the framework, device builds compile and run fine. For simulator, it fails with this error:

error: While building for iOS Simulator, no library for this platform was found

If I don't link the framework, simulator builds and runs fine, but on devices I get a dyld error at runtime.

These results are understandable, but I'd like to know if it's possible to include the xcframework only for device builds, as this would seem to solve my problems...

Any help would be appreciated.

Replies

Just checking in to see if you ever figured this out? We're in a similar boat and would love to solve the problem as well.

Hi,

I've got a similar issue - I need to link a static lib only when certain feature flag is set, so it's not linked at all when the feature is disabled. I'm struggling with shell scripts, trying to inject linker flag conditionally, but no success, it seems the ld args are overwritten every time at link phase. Any help is highly appreciated! Thanx