Follow

How can I disable Bitcode support?

Symptoms

  •  I am developing a game for iOS platform
  •  I want to set ENABLE_BITCODE=NO in the Xcode project as the default setting for a Xcode project exported by Unity.
  • I have several third party libraries which still do not support Bitcode on iOS. 

Cause

In version 5.3.1p1 Bitcode support was enabled by default. 

Resolution

An easy way to disable Bitcode support is by using UnityEditor.iOS.Xcode.PBXProject helper class.

The documentation is available here:

And the source code is available here :


The following is an example of how you can change the ENABLE_BITCODE property:

using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

public static class MyBuildPostprocess
{
    [PostProcessBuild(999)]
    public static void OnPostProcessBuild( BuildTarget buildTarget, string path)
    {
        if(buildTarget == BuildTarget.iOS)
        {
            string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject pbxProject = new PBXProject();
            pbxProject.ReadFromFile(projectPath);

            string target = pbxProject.TargetGuidByName("Unity-iPhone");            
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            pbxProject.WriteToFile (projectPath);
        }
    }
}

More Information

It is not recommend to disable Bitcode, but there are cases were it is inevitable. Read more about what benefits you gain by letting Bitcode enabled here.  

This article applies to Unity versions 5.3.1p1 and higher

Was this article helpful?
2 out of 3 found this helpful
Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Tom Kane

    This was really useful, thanks. We were having issues with our iOS build and this has fixed it.

  • 0
    Avatar
    Andrey Dolgov

    Doesn't work on compiling in Cloud Build:

    error CS0234: The type or namespace name 'Callbacks' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
    error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
    error CS0246: The type or namespace name 'BuildTarget' could not be found (are you missing a using directive or an assembly reference?) error CS0246: The type or namespace name 'PostProcessBuildAttribute' could not be found (are you missing a using directive or an assembly reference?) error CS0246: The type or namespace name 'PostProcessBuild' could not be found (are you missing a using directive or an assembly reference?)

    Is there a way to configure Cloud Build to disable bitcode?

  • 0
    Avatar
    Edd Smith

    Andrey Dolgov - My guess would be that you've not put the script in an Editor folder which is why it can't find those classes.

Please sign in to leave a comment.