Cysharp / YetAnotherHttpHandler

YetAnotherHttpHandler brings the power of HTTP/2 (and gRPC) to Unity and .NET Standard.
MIT License
350 stars 31 forks source link

iOS Unity Cloud Build Failing #20

Open jehowell opened 1 year ago

jehowell commented 1 year ago

We can't seem to get YetAnotherHttpHandler building in Unity Cloud Build for iOS

We get a linker error:

[error] [2023-09-20T04:48:30.206Z] - 7.3.22.2.7.4 - INFO: ❌ ld: could not reparse object file in bitcode bundle: 'Opaque pointers are only supported in -opaque-pointers mode (Producer: 'LLVM16.0.2-rust-1.70.0-stable' Reader: 'LLVM APPLE_1_1400.0.29.202_0')', using libLTO version 'LLVM version 14.0.0, (clang-1400.0.29.202)' for architecture arm64

The latest version of xcode that Unity supports is 14.2. Was this built with something later?

jehowell commented 1 year ago

Disabling ENABLE_BITCODE in the project does seem to solve the problem, but its not a great long term solution. Looks like there's some build settings for the native lib that are missing.

ben-tbotlabs commented 1 year ago
#if UNITY_IOS
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;

public class DisableBitCode : IPostprocessBuildWithReport
{
    public int callbackOrder => 1;

    public void OnPostprocessBuild(BuildReport report)
    {
        if (report.summary.platform == BuildTarget.iOS)
        {
            string projectPath = report.summary.outputPath + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject pbxProject = new PBXProject();
            pbxProject.ReadFromFile(projectPath);

            //Disabling Bitcode on all targets

            //Main
            string target = pbxProject.GetUnityMainTargetGuid();
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            //Unity Tests
            target = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            //Unity Framework
            target = pbxProject.GetUnityFrameworkTargetGuid();
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            // Game Assembly
            target = pbxProject.TargetGuidByName("GameAssembly");
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            pbxProject.WriteToFile(projectPath);
        }
    }
}
#endif

This is a script you can add to your project to disable the bitcode

Last8Exile commented 1 week ago

Bitcode is deprecated by Apple in Xcode 14. You can (and should) disable it.