Search Unity

Bitcode bundle could not be generated Issue

Discussion in 'Unity Build Automation' started by Saravana_Vins, May 25, 2020.

  1. Saravana_Vins

    Saravana_Vins

    Joined:
    May 5, 2017
    Posts:
    35
    Hi All,
    I am developing cross platform multiplayer application using Oculus SDK. I got the following error when I trying to build IPA file for iPhone through Unity Cloud build Dashboard. Help me to fix this issue.

    470: ▸ ❌; ld: bitcode bundle could not be generated because '/BUILD_PATH/vinsinfo-private-limited.globaloffshorevr10prnibmq/temp20200525-7005-1m4i1nb/Libraries/Oculus/LipSync/Plugins/iOS/libOVRLipSyncShim.a(OVRLipSyncShim.cpp.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
    471: ▸ ❌; clang: error: linker command failed with exit code 1 (use -v to see invocation)


    Unity Editor : 2019.3.3f1
    Oculus SDK : 1.47

    Thanks in advance.
     
  2. rtrypuchuuuge

    rtrypuchuuuge

    Joined:
    May 14, 2019
    Posts:
    9
    I have same issue. I even added code to disable BITCODE but still didn't help - on local Mac it is working
    Code (CSharp):
    1. [UsedImplicitly]
    2.     public class DisablingBitcodeiOSFixer : iOSProjectBaseFixer
    3.     {
    4.         public override int callbackOrder => 101;
    5.  
    6.         protected override bool Process(PBXProject project, string targetGuid, string projectPath)
    7.         {
    8.             project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
    9.             return true;
    10.         }
    11.     }
    Unity Editor : 2019.3.13f1 - local and UCB
    additionally UCB is adding Unity ads package to builds without any reason
    Code (CSharp):
    1. [Unity] Start importing Packages/com.unity.ads/Plugins/iOS/UnityAds.framework/Headers/NSString+UnityAdsError.h using Guid(61446b77a54b94d6dab5899c355edeb2) Importer(-1,00000000000000000000000000000000)
     
  3. rtrypuchuuuge

    rtrypuchuuuge

    Joined:
    May 14, 2019
    Posts:
    9
    I made some tests and this problem with Bitcode (even if you have code to disable it ) on UCB is when using Xcode 11.3.1 and Unity 2019.3. It is building games when using Xcode 11.0.0
    But it would be nice to have solution for this, looks like a bug on UCB
     
  4. rtrypuchuuuge

    rtrypuchuuuge

    Joined:
    May 14, 2019
    Posts:
    9
    Ok I did fix it. Setting
    pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
    Is not changing all ENABLE_BITCODE entries

    Instead use:

    Code (CSharp):
    1.  public class DisablingBitcodeiOS
    2.     {
    3.         [PostProcessBuild( 1000 )]
    4.         public static void PostProcessBuildAttribute( BuildTarget target, string pathToBuildProject )
    5.         {
    6.             if(target == BuildTarget.iOS)
    7.             {
    8.                 string projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
    9.  
    10.                 PBXProject pbxProject = new PBXProject();
    11.                 pbxProject.ReadFromFile(projectPath);
    12. #if UNITY_2019_3_OR_NEWER
    13.                 var targetGuid = pbxProject.GetUnityMainTargetGuid();
    14. #else
    15.                 var targetName = PBXProject.GetUnityTargetName();
    16.                 var targetGuid = pbxProject.TargetGuidByName(targetName);
    17. #endif        
    18.                 pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
    19.                 pbxProject.WriteToFile (projectPath);
    20.                
    21.                 var projectInString = File.ReadAllText(projectPath);
    22.  
    23.                 projectInString = projectInString.Replace("ENABLE_BITCODE = YES;",
    24.                     $"ENABLE_BITCODE = NO;");
    25.                 File.WriteAllText(projectPath, projectInString);
    26.             }
    27.         }
    28.     }
     
  5. natepacyga

    natepacyga

    Joined:
    Apr 7, 2015
    Posts:
    27
    Holy moly you are a live saver! What a deep rooted problem. I had the same issue as I was getting bit code errors even though I was setting it to "NO" (which is dumb it's not "false" like every other normal programming paradigm out there.

    This part was the magic:
    1. var projectInString = File.ReadAllText(projectPath);

    2. projectInString = projectInString.Replace("ENABLE_BITCODE = YES;",
    3. $"ENABLE_BITCODE = NO;");
    4. File.WriteAllText(projectPath, projectInString);
    This is needed because deep in the project string is this:

    56E860801D6757FF00A1AB2B /* ReleaseForRunning */ = {
    9929: [Unity] isa = XCBuildConfiguration;
    9930: [Unity] buildSettings = {
    9931: [Unity] ARCHS = armv7;
    9932: [Unity] "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
    9933: [Unity] ENABLE_BITCODE = YES;
    9934: [Unity] GCC_C_LANGUAGE_STANDARD = c11;
    9935: [Unity] GCC_ENABLE_CPP_EXCEPTIONS = NO;
    9936: [Unity] GCC_ENABLE_CPP_RTTI = NO;
    9937: [Unity] GCC_ENABLE_OBJC_EXCEPTIONS = NO;
    9938: [Unity] GCC_THUMB_SUPPORT = NO;
    9939: [Unity] GCC_USE_INDIRECT_FUNCTION_CALLS = NO;
    9940: [Unity] GCC_WARN_ABOUT_RETURN_TYPE = YES;
    9941: [Unity] GCC_WARN_UNUSED_VARIABLE = YES;
    9942: [Unity] PRODUCT_NAME_APP = gametacosdkv2;
    9943: [Unity] SDKROOT = iphoneos;
    9944: [Unity] SUPPORTED_PLATFORMS = iphoneos;
    9945: [Unity] };
    9946: [Unity] name = ReleaseForRunning;

    There is one enable bitcode that is missed! COME ON!!! This is the types of issues that drive engineers crazy...
     
    CodeRonnie, thiha_gtm and Chopium like this.
  6. pland

    pland

    Joined:
    Mar 26, 2016
    Posts:
    3
    Where do you put this script in the Unity project for it to kick in though?
     
  7. bhupiister

    bhupiister

    Joined:
    Dec 13, 2019
    Posts:
    42
    Just create folder by the name Editor in the assets folder and put it inside it, no need to attach it to some gameobject.
    You can YouTube "PostProcessBuild" and will get lots of information on it.
     
  8. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Was this fixed yet? Seems not...
    If doing an Xcode build you can find the one manual setting for bitcode if you do not want an extra script
     
    Last edited: Apr 25, 2022
  9. xT1TANx

    xT1TANx

    Joined:
    Nov 16, 2017
    Posts:
    17
    Can you elaborate? Where is the one setting?


    For anyone reading this later and has the same problem:
    I found the setting.
    In XCode -> Build Settings
    At the top "Customised" is auto selected. This hides all other flags but the ones that have been edited( by unity I assume ). If you click "All" the rest appear including Enable Bitcode. Then you can set it.

    However this doesn't fix the Archive problem. I am able to build to my ios Device perfectly, but when I archive I am hit with

    Plugin was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
     
    Last edited: Aug 2, 2022
  10. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Under build settings there is a setting but it's no longer working for me so had to use found code like above instead.

    Unity could really help us by getting on top of xcode setup within the editor but apple ain't helping developers!
     
  11. samuelmorais

    samuelmorais

    Joined:
    Aug 3, 2012
    Posts:
    62
    I am using in a project Unity 2020.1 and I can confirm that this script works, if put in the Editor folder, of course.
     
  12. unity_icE-j4aJVpNSbw

    unity_icE-j4aJVpNSbw

    Joined:
    Dec 22, 2020
    Posts:
    1
    above script solution worked for me thanks buddy. And guys if you get any File issue must add below things on top of the script.

    using System;
    using System.IO;
    using System.Text;
     
  13. triduzak

    triduzak

    Joined:
    Jan 24, 2021
    Posts:
    3
    This is awesome, thank you!

    For those who is noob like me:))
    create Folder "Editor" in Assets, create new c# script, put in header:
    using System.IO;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using UnityEditor.iOS.Xcode;

    and then copy quoted code.
    When building project from Unity, erase everything from build folder, because xcode project settings might remain and will not be overwritten.
     
    farazk86, MaceB and CrimeCrew like this.