I have a static library that is built by other company. I want to know if it's a static library containing bitcode, which command can detect it in terminal?
Bitcode-enabled builds When this option is disabled, the compiler generates an executable file that only contains machine code. But when it is enabled, the bitcode is included in the executable file alongside the generated machine code.
For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required.
As it was alread written in other answers,
otool -l yourlib.a | grep __LLVM
is the way to go.
An Apple engineer says using
otool -l yourlib.a | grep bitcode
is not reliable.
Searching for a "bitcode" section is not a reliable way to detect if your files contain embedded bitcode. If you want to do that, search for the "__LLVM" segment. You should be aware that a normal build with the -fembed-bitcode-marker option will produce minimal size embedded bitcode sections without any real content. This is done as a way of testing the bitcode-related aspects of your build without slowing down the build process. The actual bitcode content is included when you do an Archive build.
See also the comments by xCocoa.
It seems, that otool
does not report the bitcode if code for the iPhone Simulator's architecture is included (x86_64 or i386).
You can list the lib's architectures with:
lipo -info yourlib.a
Then you can check for bitcode for each architecture separately, e.g:
otool -arch armv7 -l yourlib.a | grep bitcode otool -arch arm64 -l yourlib.a | grep bitcode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With