I work on an iOS app, written in Objective-C and C++, that uses a static library. I build this library using a Run Script in Build Phases in Xcode. This is a fat library, containing arm64 code built for iPhoneOS, and x86_64 code built for iPhoneSimulator.
I'm trying to figure out how to create an arm64 iPhoneSimulator build of my app, and I'm running into a problem. If I simply enable arm64 debug builds, I get an error message saying "building for iOS Simulator, but linking in object file built for iOS", indicating that the arm64 iPhoneOS code in the library is not compatible with an arm64 iPhoneSimulator target.
Now, I can build the library as arm64 for iPhoneSimulator, but that means I'll have to build a separate library for the simulator build, since lipo won't combine arm64 iPhoneOS and arm64 iPhoneSimulator builds in one file.
My question: how can I get Xcode to link with a different library for iPhoneSimulator builds than for iPhoneOS builds? All I can come up with is to use completely separate targets for debugging in the simulator vs. debugging on a real device, but that seems ugly.
(It would be even better if I could use the same library for both arm64 iPhoneSimulator and iPhoneOS builds. The library in question is a math library which makes no system calls, so I think the same code should be usable for both builds, if only I could get the linker to allow that.)