Reputation: 1025
We are facing problems with lipo/libtool when trying to build a fat static lib for simulator and device. Before M1 arm64 all went fine with an armv7/arm64 slices for the device and an x86_64 slice for the simulator. Now lipo can't spot the difference between the arm64 build for simulator and the arm64 build for the device and refuses to add 2 arm64 slices.
Is there a way to build a 'generic' arm64 lib slice (because the code in our lib is platform agnostic)
Are there other tools to achieve packing 2 arm64 slices into a .a or do we need to build now 2 separate static libs for simulator and device ? (Please note we do not use Xcode for building, so we are just linking on the command line).
Interestingly when linking against dynamic standard libs such as libxml a -lxml is sufficient regardless of the platform however this is for dynamic libs, not static. Does a similar mechanism exist for static libs ?
Upvotes: 6
Views: 1114
Reputation: 1025
We ended up in creating 2 separate versions of all our static libs: one containing the arm64 code for the device and one containing both the x86_64 and arm64 slices for the simulator. The command line trick to create both simulator slices for an object in one rush when compiling with clang is
clang -target x86-apple-ios-simulator -target arm64-apple-ios-simulator -arch x86_64 -arch arm64 ...
When linking we have separate suffixes, for ex libFOO_S.a for the simulator lib and pick the suitable depending on if building for the simulator or not. I didn't find a way to have all slices for device/simulator in one fat .a ... it's simply not foreseen.
Upvotes: 1