Last active
March 20, 2023 03:29
-
-
Save dangkhoasdc/d365ceb194735bf2c99b08934703e6f3 to your computer and use it in GitHub Desktop.
Automatically disabling bitcode for iOS build on Unity
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
// Place this script in Assets > Editor | |
public class DisablingBitcodeiOS | |
{ | |
[PostProcessBuild( 1000 )] | |
public static void PostProcessBuildAttribute( BuildTarget target, string pathToBuildProject ) | |
{ | |
if(target == BuildTarget.iOS) | |
{ | |
string projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject); | |
PBXProject pbxProject = new PBXProject(); | |
pbxProject.ReadFromFile(projectPath); | |
#if UNITY_2019_3_OR_NEWER | |
var targetGuid = pbxProject.GetUnityMainTargetGuid(); | |
#else | |
var targetName = PBXProject.GetUnityTargetName(); | |
var targetGuid = pbxProject.TargetGuidByName(targetName); | |
#endif | |
pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO"); | |
pbxProject.WriteToFile (projectPath); | |
var projectInString = File.ReadAllText(projectPath); | |
projectInString = projectInString.Replace("ENABLE_BITCODE = YES;", | |
$"ENABLE_BITCODE = NO;"); | |
File.WriteAllText(projectPath, projectInString); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment