Bitcode bundle could not be generated Issue

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: ▸ :x:; 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: ▸ :x:; 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.

I have same issue. I even added code to disable BITCODE but still didn’t help - on local Mac it is working

[UsedImplicitly]
    public class DisablingBitcodeiOSFixer : iOSProjectBaseFixer
    {
        public override int callbackOrder => 101;

        protected override bool Process(PBXProject project, string targetGuid, string projectPath)
        {
            project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
            return true;
        }
    }

Unity Editor : 2019.3.13f1 - local and UCB
additionally UCB is adding Unity ads package to builds without any reason

[Unity] Start importing Packages/com.unity.ads/Plugins/iOS/UnityAds.framework/Headers/NSString+UnityAdsError.h using Guid(61446b77a54b94d6dab5899c355edeb2) Importer(-1,00000000000000000000000000000000)

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

Ok I did fix it. Setting
pbxProject.SetBuildProperty(targetGuid, “ENABLE_BITCODE”, “NO”);
Is not changing all ENABLE_BITCODE entries

Instead use:

 public class DisablingBitcodeiOS
    {
        [PostProcessBuild( 1000 )]
        public static void PostProcessBuildAttribute( BuildTarget target, string pathToBuildProject )
        {
            if(target == BuildTarget.iOS)
            {
                string projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);

                PBXProject pbxProject = new PBXProject();
                pbxProject.ReadFromFile(projectPath);
#if UNITY_2019_3_OR_NEWER
                var targetGuid = pbxProject.GetUnityMainTargetGuid();
#else
                var targetName = PBXProject.GetUnityTargetName();
                var targetGuid = pbxProject.TargetGuidByName(targetName);
#endif         
                pbxProject.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
                pbxProject.WriteToFile (projectPath);
               
                var projectInString = File.ReadAllText(projectPath);

                projectInString = projectInString.Replace("ENABLE_BITCODE = YES;",
                    $"ENABLE_BITCODE = NO;");
                File.WriteAllText(projectPath, projectInString);
            }
        }
    }
15 Likes

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:

  • var projectInString = File.ReadAllText(projectPath);
    • projectInString = projectInString.Replace(“ENABLE_BITCODE = YES;”,
  • $“ENABLE_BITCODE = NO;”);
  • 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…

3 Likes

Where do you put this script in the Unity project for it to kick in though?

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.

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

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

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!

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.

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;

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.

3 Likes