Created
April 6, 2021 13:03
-
-
Save guneyozsan/2f503015268e04748e0283da562b448c to your computer and use it in GitHub Desktop.
Unity 3D - Disable bitcode compilation on iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found a more recent solution
https://support.unity.com/hc/en-us/articles/207942813-How-can-I-disable-Bitcode-support-