Skip to content

Instantly share code, notes, and snippets.

@dangkhoasdc
Last active March 20, 2023 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangkhoasdc/d365ceb194735bf2c99b08934703e6f3 to your computer and use it in GitHub Desktop.
Save dangkhoasdc/d365ceb194735bf2c99b08934703e6f3 to your computer and use it in GitHub Desktop.
Automatically disabling bitcode for iOS build on Unity
// 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