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?
And if you want to check if a specific file (yourFile.o) in the static library is bitcode enabled, you can extract the 'staticLibrary.a' and use the same otool command. However macOS doesn't allow to extract your staticLibrary.a at times with the default extract utility and most 3rd party tools doesn't work either.
You can follow these steps to check specific .o files
Get the info of the architecture
lipo -info yourStaticLibrary.a
eg output: armv7 arm64
Extract yourStaticLibrary.a for any or both of the above architecture
lipo yourStaticLibrary.a -thin armv7 -output yourStaticLibraryarmv7.a
(specify the output path you want to extract to)
You get the 'yourStaticLibraryarmv7.a' which then can be easily extracted with the default mac unarchiver
On extracting, you then get a folder 'yourStaticLibraryarmv7' containing all the .o files
otool -l yourFile.o | grep bitcode
or with the specific architecture
otool -arch armv7 -l yourFile.o | grep bitcode
If the file is bitcode enabled , you get 'sectname __bitcode' in the commandline