How to check a static library is built contain bitcode?

xCocoa picture xCocoa · Sep 24, 2015 · Viewed 20.2k times · Source

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?

Answer

Oliver picture Oliver · Oct 13, 2015

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