What Does Enable_Bitcode Do in Xcode 7

What does ENABLE_BITCODE do in xcode 7?

Bitcode refers to to the type of code: "LLVM Bitcode" that is sent to iTunes Connect. This allows Apple to use certain calculations to re-optimize apps further (e.g: possibly downsize executable sizes). If Apple needs to alter your executable then they can do this without a new build being uploaded.

This differs from:
Slicing which is the process of Apple optimizing your app for a user's device based on the device's resolution and architecture. Slicing does not require Bitcode. (Ex: only including @2x images on a 5s)

App Thinning is the combination of slicing, bitcode, and on-demand resources

Bitcode is an intermediate representation of a compiled program. Apps
you upload to iTunes Connect that contain bitcode will be compiled and
linked on the App Store. Including bitcode will allow Apple to
re-optimize your app binary in the future without the need to submit a
new version of your app to the store.

Apple Documentation on App Thinning

How to ENABLE_BITCODE in Xcode 7?

If you are using a third-party framework or library that was updated for iOS 9, and you don't want to include bitcode, then you should check to see if a version of the framework was provided without bitcode. See Apple's note on when to include it in your app bundle:

For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode.

To disable/enable bitcode in your project, follow these steps:

  1. In the project build settings, make sure you have enabled All settings to be visible.
  2. The Build Options are the 4th section down. Select Yes or No for the Enable Bitcode option.

Sample Image

Sample Image

Impact of Xcode build options Enable bitcode Yes/No

  • What does the ENABLE_BITCODE actually do, will it be a non-optional requirement in the future?

I'm not sure at what level you are looking for an answer at, so let's take a little trip. Some of this you may already know.

When you build your project, Xcode invokes clang for Objective-C targets and swift/swiftc for Swift targets. Both of these compilers compile the app to an intermediate representation (IR), one of these IRs is bitcode. From this IR, a program called LLVM takes over and creates the binaries needed for x86 32 and 64 bit modes (for the simulator) and arm6/arm7/arm7s/arm64 (for the device). Normally, all of these different binaries are lumped together in a single file called a fat binary.

The ENABLE_BITCODE option cuts out this final step. It creates a version of the app with an IR bitcode binary. This has a number of nice features, but one giant drawback: it can't run anywhere. In order to get an app with a bitcode binary to run, the bitcode needs to be recompiled (maybe assembled or transcoded… I'm not sure of the correct verb) into an x86 or ARM binary.

When a bitcode app is submitted to the App Store, Apple will do this final step and create the finished binaries.

Right now, bitcode apps are optional, but history has shown Apple turns optional things into requirements (like 64 bit support). This usually takes a few years, so third party developers (like Parse) have time to update.

  • can I use the above method without any negative impact and without compromising a future appstore submission?

Yes, you can turn off ENABLE_BITCODE and everything will work just like before. Until Apple makes bitcode apps a requirement for the App Store, you will be fine.

  • Are there any performance impacts if I enable / disable it?

There will never be negative performance impacts for enabling it, but internal distribution of an app for testing may get more complicated.

As for positive impacts… well that's complicated.

For distribution in the App Store, Apple will create separate versions of your app for each machine architecture (arm6/arm7/arm7s/arm64) instead of one app with a fat binary. This means the app installed on iOS devices will be smaller.

In addition, when bitcode is recompiled (maybe assembled or transcoded… again, I'm not sure of the correct verb), it is optimized. LLVM is always working on creating new a better optimizations. In theory, the App Store could recreate the separate version of the app in the App Store with each new release of LLVM, so your app could be re-optimized with the latest LLVM technology.

What are the effects of disabling BitCode in Xcode project settings?

Turning it off simply means that your app will live on the app store the same way it did before Xcode 7 & Bitcode. When it's downloaded, binary code for all supported architectures get downloaded from the App Store.

If you turn BitCode on, then the intermediate representation of the compiled program gets uploaded and Apple will able to recompile and/or optimize your apps for future architectures (as described here).

Turning it off is very safe for the time being.

More information can be found in this related question.

And like you, I'm waiting for certain third party libraries to be updated for BitCode support (in my case, it's the Google Analytics library).

dont run app with open-cv in xcode 7?

In the build settings for your App Target, search for "Bitcode" and set Bitcode Enabled to NO.


Although I recommend you get the framework vendor to supply a Bitcode enabled version



Related Topics



Leave a reply



Submit