ipraba
ipraba

Reputation: 16553

How to check if a framework is Bitcode supported for Xcode7

From Xcode 7 it became one of the common problem that third party frameworks should support Bitcode. We can also disable the BITCODE by setting ENABLE_BITCODE to NO in Build settings. But i do not want to turn it off, instead i want to convert all my frameworks to BITCODE compatible.

So how to check if a framework is BITCODE compatible apart from compiling the framework in Xcode. Sometimes Xcode give error for BITCODE compatibility for one framework leaving the others even though they don't have BITCODE support.

Is there any tool/command line check?

Upvotes: 34

Views: 17819

Answers (6)

yoAlex5
yoAlex5

Reputation: 34311

One more approach

otool -v -s __LLVM __bundle <binary_path>
//e.g.
otool -v -s __LLVM __bundle "/Users/alex/MyModule.framework/MyModule" 

or to find __bundle section in __LLVM segment

otool -l <binary_path> | grep __bundle 

[Bitcode]

Upvotes: 0

SnehaK
SnehaK

Reputation: 151

I have observed that __bitcode section is only present for static Libs and not for dynamic libs. So, one 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

Upvotes: 8

rustyMagnet
rustyMagnet

Reputation: 4095

Set the flag in the Targets:

enter image description here

Bitcode enabled

otool -arch arm64 -l myFramework | grep __LLVM
  segname __LLVM
   segname __LLVM

I ( wrongly ) expected to read the same output against a local iOS app build. That was not the case. The same command produced nothing, despite have ENABLE_BITCODE YES. Only when you selected Archive did the bitcode process start.

This answer helped me:

What's the difference between `-fembed-bitcode` and BITCODE_GENERATION_MODE?

Upvotes: 1

naresh d
naresh d

Reputation: 183

you can try these commands:

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

and

otool -arch arm64 -l libDeviceManager.a | grep bitcode

Upvotes: 1

Michael M. Myers
Michael M. Myers

Reputation: 2515

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.

Upvotes: 58

Mecki
Mecki

Reputation: 133139

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.

Upvotes: 17

Related Questions