How to check if a framework is BITCODE supported for Xcode7

為{幸葍}努か 提交于 2019-11-28 04:10:53
Michael M. Myers

From this Apple Developers Forum discussion, user dshirley and bwilson suggest using command line tools otool and grep to check if bitcode sections exist.

$ otool -l libName.o | grep __LLVM

or

$ otool -l MyFramework.framework/Versions/A/MyFramework | grep __LLVM

Running the above command, if the library contains bitcode you will see segname __LLVM output.

The accepted answer suggests you shall do grep __LLVM but I'd rather do this

otool -l libName.o | grep __bitcode

as there are different __LLVM segments and not all of these indicate the presence of Bitcode. Here's an example:

Section
  sectname __bitcode
   segname __LLVM
      addr 0x00000000000007d0
      size 0x0000000000000f10
    offset 3360
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cmdline
   segname __LLVM
      addr 0x00000000000016e0
      size 0x0000000000000069
    offset 7216
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0

The presence of the __cmdline Section does not indicate that Bitcode is present, yet it would also be found when just searching for __LLVM.

SnehaK

I have observed that __bitcode section is only present for static Libs and not for dynamic libs. So, on solution is the below command.

otool -l libDeviceManager.a | grep __LLVM 

Also, sometimes with fat binaries otool may not give __LLVM segments even though they are present. You can use the following command for those cases

otool -arch armv7 -l libDeviceManager.framework/libDeviceManager | grep __LLVM
naresh d

you can try these commands:

otool -arch armv7 -l libDeviceManager.a | grep bit code

and

otool -arch arm64 -l libDeviceManager.a | grep bitcode
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!