Disable bitcode in XCode project as postprocessbuild activity

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.");
        }
    }
}

Hi there, if you’re still having this issues, check out the bottom of this thread, the solution is a string replace… Don’t even get me started…

Aaah yes, another build process to miraculously fail in the future when they change the pbx structure to say:

ENABLE_BITCODE = TRUE

Seriously… YES? YES ??!!! Who designed this, COBOL programmers?!

2 Likes

Love it @Kurt-Dekker ! I lol’ed for real at your comment. :wink:
Hey man, since you’re in the trenches with me on the whole FB SDK junk, could you take a look at this one I am having trouble with? https://forum.unity.com/threads/facebook-sdk-error-symbols-tool-failed-or-linker-errors.1009984/ Let me know if you have any experience with it.