Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling iOS library with bitcode enabled

I need to release a framework with bitcode enabled which turns out as a hassle. I set 'Enable Bitcode' in the project's settings to 'YES' and it builds cleanly for both a real device and a simulator.

I wanted to test the library so I integrated it to a new app I created for this purpose but now it only build for simulators. When I try to build for a real device I get:

ld: '/path/to/Framework.framework/Company(File.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Like I said, I had built it with Bitcode enabled so I'm not sure why this happens.

Any ideas? thanks

like image 995
Yotam Avatar asked Sep 30 '15 14:09

Yotam


People also ask

Should I include Bitcode for iOS content?

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.

Should I enable Bitcode iOS?

Bitcode will allow apple to optimise the app without you having to submit another build. But, you can only enable this feature if all frameworks and apps in the app bundle have this feature enabled. Having it helps, but not having it should not have any negative impact.

What does enable Bitcode do iOS?

Enable bitcode Bitcode is an Apple technology that enables you to recompile your app to reduce its size. The recompilation happens when you upload your app to App Store Connect or export it for Ad Hoc, Development, or Enterprise distribution.

Does Apple require Bitcode?

Including Bitcode is optional for iOS apps, but mandatory for watchOS or tvOS apps. "Meaning you can slice/segment it out for different processors, etc. once it's in the store, reducing the payload do the user accordingly."


1 Answers

AFAIK, when you build app with Xcode it includes Bitcode only when you make archive, the reason - decrease compile time when just want to debug or test the app/library.

To ensure that Xcode emits bitcode at each build you can add -fembed-bitcode flag to Other C flags and Other linker flags:

enter image description here

enter image description here

Also, the easiest way to check if the binary contains bitcode is to use otool and grep:

otool -l binary_name | grep __LLVM

you will see one or more segname __LLVM entries if it does have bitcode or empty output if does not.

like image 162
AlexDenisov Avatar answered Sep 21 '22 04:09

AlexDenisov