Creating/Utilizing Bitcode Library

I am trying to wrap my head around creating and using bitcode libraries. I am compiling a library from the command line, and first used -fembed-bitcode-marker. That caused xcode to stop showing the error that the library needed to be recompiled with bitcode when running on the device. However, then I get the error :


full bitcode bundle could not be generated because XX/XX was built only with bitcode marker. The library must be generated from Xcode archive build with bitcode enabled


I saw on another site, that is due to the fact, that the library needs to be built using -fembed-bitcode (not -fembed-bitcode-marker), so I did that. Now, when I try to archive, xcode says:

ld: warning: ignoring file X, file was built for archive which is not the architecture being linked (arm64).

However, with this new library, I can install install my project onto my device with no warnings about bitcode needing to be enabled (and I assume that now it actually enabled vs. when I compiled using -fembed-bitcode-marker). So, why does ld show this warning when trying to archive, since it builds and runs fine on the device (running on the simulators shows the same error).

Accepted Reply

Thanks to bwilson for the answer (https://forums.developer.apple.com/message/7038#7038):


"Yes, the armv7 and arm64 architectures are still separate, even when using bitcode. That would explain why it wasn't working for you. Bitcode does not eliminate the need for "fat" libraries, at least for the existing architectures." -bwilson

Replies

I just built a library in Xcode and realized that it builds for architectures of armv7 and arm64 when you make a bitcode library. I'm assuming this is why mine isn't working, as I was only using an armv7 bitcode library. However, I thought the whole purpose of bitcode was to eliminate fat binaries/libraries. Can someone explain what I'm misinterpreting?

Thanks to bwilson for the answer (https://forums.developer.apple.com/message/7038#7038):


"Yes, the armv7 and arm64 architectures are still separate, even when using bitcode. That would explain why it wasn't working for you. Bitcode does not eliminate the need for "fat" libraries, at least for the existing architectures." -bwilson