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 2 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.