iOS library to BitCode

When building static libraries you must add the following for bitcode generation:

-fembed-bitcode 

for a dynamic library you need to additionally link with

-fembed-bitcode

Note: This command is only available with Xcode7+

In regards to the accepted answer of using -fembed-bitcode-marker

You should be aware that a normal build with the -fembed-bitcode-marker option will produce minimal size embedded bitcode sections without any real content. This is done as a way of testing the bitcode-related aspects of your build without slowing down the build process. The actual bitcode content is included when you do an Archive build.

bwilson Apple Staff. https://forums.developer.apple.com/thread/3971#12225


To be more specific:

  • -fembed-bitcode-marker simply marks where the bitcode would be in the binary after an archive build.
  • -fembed-bitcode actually does the full bitcode generation and embedding, so this is what you need to use for building static libraries.
  • Xcode itself builds with -fembed-bitcode-marker for regular builds (like deploy to simulator)
  • Xcode only builds with -fembed-bitcode for archive builds / production builds (as this is only needed for Apple).

Go the Build Settings. Search for "custom compiler flags".
Add -fembed-bitcode to Other C Flags. This will ensure that the lib is built with bitcode compatibility at compile time. I made this for iOS 64 bit and 32 bit, and lipo'd them into one. Works like a charm.

Since you guys had queries, here's a screenshot of the settings: The settings are same for the project target and the SDK target.

enter image description here


The bitcode lib will not work with Xcode 6.


If you're still having trouble after adding the -fembed-bitcode to the Other C flags, search for "Enable Bitcode" under "Build Options" and set it to No. This will allow you to archive properly.