Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guneyozsan/2f503015268e04748e0283da562b448c to your computer and use it in GitHub Desktop.
Save guneyozsan/2f503015268e04748e0283da562b448c to your computer and use it in GitHub Desktop.
Unity 3D - Disable bitcode compilation on iOS
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using UnityEngine;
public class BuildProcessorBitcodeCompilationDisabler
{
[PostProcessBuild(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
#if UNITY_IOS
DisableBitcodeOnIos(buildTarget, path);
#endif
}
#if UNITY_IOS
/// <summary>
/// Disables bitcode compilation on iOS platform.
/// </summary>
// From https://support.unity3d.com/hc/en-us/articles/207942813-How-can-I-disable-Bitcode-support-
private static void DisableBitcodeOnIos(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iOS)
{
return;
}
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
var pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);
string target = pbxProject.TargetGuidByName("Unity-iPhone");
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
pbxProject.WriteToFile(projectPath);
Debug.Log("Post Process Build - SUCCESS: Disable bitcode on IOS\n" +
"Bitcode setting in Xcode project is updated.");
}
#endif
}
@hvesuk
Copy link

hvesuk commented Dec 23, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment