Symptoms:
- I am developing a game for iOS.
- I want to set ENABLE_BITCODE=NO in the Xcode project as the default setting for an Xcode project exported by Unity.
- I have several third-party libraries which still do not support Bitcode on iOS.
Cause:
Since Unity version 5.3.1p1, Bitcode support is 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: Unity - Scripting API: PBXProject
The following is an example of how you can change the ENABLE_BITCODE property:
using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; using UnityEngine; using UnityEditor.iOS.Xcode; class Test: IPostprocessBuildWithReport { public int callbackOrder { get { return 0; } } public void OnPostprocessBuild(BuildReport report) { if (report.summary.platform == BuildTarget.iOS) { string projectPath = report.summary.outputPath + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromFile(projectPath); //Disabling Bitcode on all targets //Main string target = pbxProject.GetUnityMainTargetGuid(); pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); //Unity Tests target = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName()); pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); //Unity Framework target = pbxProject.GetUnityFrameworkTargetGuid(); pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); pbxProject.WriteToFile(projectPath); }
More Information:
Please note: Unity does not recommend disabling Bitcode. However, there are cases where it is inevitable. Read more about what benefits you gain by enabling Bitcode in the article, 'Bitcode Support in iOS & tvOS.'
This article applies to Unity versions 2018.1 and higher.