Hi developers,
I am trying to disable BITCODE setting in a build XCode project from Unity. I understood that i have to make a postprocess method that will set the bitcode to NO.
I used the following code. But still when i open the XCode project the value is still YES. That is why i can’t build now in Unity Cloud build for iOS. Can someone help me finding out what i am doing wrong? I put this file in an Editor map in my project hierarchy and see that the debug statement at the end has run.
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
namespace MMM.BuildPostProcess
{
/// <summary>
/// This class manages the post build process
/// </summary>
public static class BuildPostProcess
{
[PostProcessBuildAttribute(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget != BuildTarget.iOS) return;
// change bitcode to false
var projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
Debug.Log("[BuildPostprocess] Build iOS. path: " + projPath);
var proj = new PBXProject();
var file = File.ReadAllText(projPath);
proj.ReadFromString(file);
var target = proj.GetUnityMainTargetGuid();
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
File.WriteAllText(projPath, proj.WriteToString());
Debug.Log("[BuildPostprocess] Bitcode disabled.");
}
}
}