Search Unity

Disable bitcode in XCode project as postprocessbuild activity

Discussion in 'Editor & General Support' started by multimediamarkers, Sep 24, 2020.

  1. multimediamarkers

    multimediamarkers

    Joined:
    Feb 17, 2016
    Posts:
    49
    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.

    Code (CSharp):
    1.  
    2. using System.IO;
    3. using UnityEngine;
    4. using UnityEditor;
    5. using UnityEditor.Callbacks;
    6. using UnityEditor.iOS.Xcode;
    7.  
    8. namespace MMM.BuildPostProcess
    9. {
    10.     /// <summary>
    11.     /// This class manages the post build process
    12.     /// </summary>
    13.     public static class BuildPostProcess
    14.     {
    15.         [PostProcessBuildAttribute(999)]
    16.         public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
    17.         {
    18.             if (buildTarget != BuildTarget.iOS) return;
    19.  
    20.             // change bitcode to false
    21.             var projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
    22.             Debug.Log("[BuildPostprocess] Build iOS. path: " + projPath);
    23.  
    24.             var proj = new PBXProject();
    25.             var file = File.ReadAllText(projPath);
    26.             proj.ReadFromString(file);
    27.  
    28.             var target = proj.GetUnityMainTargetGuid();
    29.  
    30.             proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
    31.  
    32.             File.WriteAllText(projPath, proj.WriteToString());
    33.  
    34.             Debug.Log("[BuildPostprocess] Bitcode disabled.");
    35.         }
    36.     }
    37. }
     
  2. natepacyga

    natepacyga

    Joined:
    Apr 7, 2015
    Posts:
    27
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    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?!
     
    masterton and natepacyga like this.
  4. natepacyga

    natepacyga

    Joined:
    Apr 7, 2015
    Posts:
    27