Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Issues with bitcode

Discussion in 'Unity Build Automation' started by gabrielesimula, Jan 9, 2023.

  1. gabrielesimula

    gabrielesimula

    Joined:
    May 21, 2020
    Posts:
    12
    Hello everyone,

    I am having a issue with bitcode, when I try to build using Cloud Build I get the following error:

    Code (CSharp):
    1. 1237: [2023-01-09T19:53:27.781Z] - 7.2.4.2.7.4 - INFO:;  ld: '/BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-aucdquakdojdtygyeoppkevqhqmj/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement/WithoutAdIdSupport/GoogleAppMeasurement.framework/GoogleAppMeasurement(APMAdExposureReporter.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-aucdquakdojdtygyeoppkevqhqmj/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement/WithoutAdIdSupport/GoogleAppMeasurement.framework/GoogleAppMeasurement' for architecture arm64
    I have a script in my Editor to disable it on post build, but apparently is not working, can please somebody advice what is wrong? thanks


    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Build;
    3. using UnityEditor.Build.Reporting;
    4. using UnityEngine;
    5. using UnityEditor.iOS.Xcode;
    6.  
    7.  
    8. class Test: IPostprocessBuildWithReport
    9. {
    10.     public int callbackOrder { get { return 0; } }
    11.     public void OnPostprocessBuild(BuildReport report)
    12.     {
    13.         if (report.summary.platform == BuildTarget.iOS)
    14.         {
    15.             string projectPath = report.summary.outputPath + "/Unity-iPhone.xcodeproj/project.pbxproj";
    16.  
    17.  
    18.             PBXProject pbxProject = new PBXProject();
    19.             pbxProject.ReadFromFile(projectPath);
    20.  
    21.  
    22.             //Disabling Bitcode on all targets
    23.  
    24.  
    25.             //Main
    26.             string target = pbxProject.GetUnityMainTargetGuid();
    27.             pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
    28.  
    29.  
    30.             //Unity Tests
    31.             target = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
    32.             pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
    33.  
    34.  
    35.             //Unity Framework
    36.             target = pbxProject.GetUnityFrameworkTargetGuid();
    37.             pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
    38.  
    39.  
    40.             pbxProject.WriteToFile(projectPath);
    41.         }
    42.  
     
  2. gabrielesimula

    gabrielesimula

    Joined:
    May 21, 2020
    Posts:
    12
    Also this doesn't work:


    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Build;
    3. using UnityEditor.Build.Reporting;
    4. using UnityEngine;
    5. using UnityEditor.iOS.Xcode;
    6.  
    7.  
    8.    [PostProcessBuild(999)]
    9.     public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
    10.     {
    11.         if (buildTarget != BuildTarget.iOS)
    12.         {
    13.             return;
    14.         }
    15.         var projPath = PBXProject.GetPBXProjectPath(path);
    16.         var project = new PBXProject();
    17.         project.ReadFromFile(projPath);
    18.         var mainTargetGuid = project.GetUnityMainTargetGuid();
    19.         foreach (var targetGuid in new[] {mainTargetGuid, project.GetUnityFrameworkTargetGuid()})
    20.         {
    21.             project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
    22.         }
    23.         project.WriteToFile(projPath);
    24.     }
     
  3. gabrielesimula

    gabrielesimula

    Joined:
    May 21, 2020
    Posts:
    12
    solved by adding
    bitcodeEnabled="false"
    to
    GoogleMobileAdsDependencies
     
  4. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Okay, so since this thread is among the top 5 in the google search here is my fix disabling bitcode for the project and all targets:
    Code (CSharp):
    1.  
    2. [PostProcessBuild]
    3. public static void OnPostProcessBuild(BuildTarget buildTarget, string builtProjectPath)
    4. {
    5.     if (buildTarget != BuildTarget.iOS)
    6.     {
    7.         return;
    8.     }
    9.  
    10.     var projectPath = PBXProject.GetPBXProjectPath(builtProjectPath);
    11.     var project = new PBXProject();
    12.     project.ReadFromFile(projectPath);
    13.  
    14.     //...
    15.  
    16.     project.SetBuildProperty(project.ProjectGuid(), "ENABLE_BITCODE", "NO");
    17.  
    18.     //...
    19.  
    20.     project.WriteToFile(projectPath);
    21. }
    22.  
     
    kreso and khaled24 like this.
  5. MuhammadHaseeb56

    MuhammadHaseeb56

    Joined:
    Mar 12, 2019
    Posts:
    13


    where we have to place this script in the project
     
  6. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Actually anywhere it suits best you.

    For example you can create a new static class and place it there:

    Code (CSharp):
    1.  
    2. public static class MyXCodePostProcessingClass
    3. {
    4.    [PostProcessBuild]
    5.    public static void OnPostProcessBuild(BuildTarget buildTarget, string builtProjectPath)
    6.    {
    7.        if (buildTarget != BuildTarget.iOS)
    8.        {
    9.            return;
    10.        }
    11.        var projectPath = PBXProject.GetPBXProjectPath(builtProjectPath);
    12.        var project = new PBXProject();
    13.        project.ReadFromFile(projectPath);
    14.        //...
    15.        project.SetBuildProperty(project.ProjectGuid(), "ENABLE_BITCODE", "NO");
    16.        //...
    17.        project.WriteToFile(projectPath);
    18.    }
    19. }
    20.