ARM64 branch out of range when building for visionOS

Hi, I’m getting the following error when building for Apple visionOS:

B(l) ARM64 branch out of range (-156236748 max is +/-128MB): from ___Il2CppComObject_Finalize_m720B2062F661A0770A32D24B731AD4AFE314A5CD (0x0954A640) to __Z40il2cpp_codegen_il2cpp_com_object_cleanupP15Il2CppComObject (0x0004AAA4) in '___Il2CppComObject_Finalize_m720B2062F661A0770A32D24B731AD4AFE314A5CD' from /Users/immortal/Library/Developer/Xcode/DerivedData/Unity-VisionOS-hkuskwknhzirrxgapfjitqljiiqs/Build/Products/Debug-xros/libGameAssembly.a(tyjo7lovil21.o) for architecture arm64

I’'m using Unity 6000.0.21f1 and here are some relevant packages I reference:

"com.unity.inputsystem": "1.11.0",
  
"com.unity.polyspatial": "2.0.4",
"com.unity.polyspatial.visionos": "2.0.4",
"com.unity.polyspatial.xr": "2.0.4",

"com.unity.xr.core-utils": "2.3.0",
"com.unity.xr.hands": "1.4.3",
"com.unity.xr.interaction.toolkit": "3.0.5",
"com.unity.xr.legacyinputhelpers": "2.1.11",
"com.unity.xr.management": "4.5.0",
"com.unity.xr.openxr": "1.12.1",
"com.unity.xr.visionos": "1.3.9",

"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0",

Another thing that might be relevant is that I’m getting a bunch of warnings like this:

Object file (/Users/immortal/Library/Developer/Xcode/DerivedData/Unity-VisionOS-hkuskwknhzirrxgapfjitqljiiqs/Build/Products/Debug-xros/libGameAssembly.a(dfhnw1sxry4d.o)) was built for newer platform=11 version (2.1) than being linked (2.0)

Note also that I was able to build the same project with some older packages and in Unity 2022.3.24f1.

Please advise, thanks!

This is a known issue with the IL2CPP compiler in current Unity 6, and the workaround is to go into Project Settings → XR Management-> Apple Vision OS and enable 'IL2CPP Large Exe Workaround`. That should get you over this hurdle for now.

We’re working with the IL2CPP team to try to remove the need for that, but for now this is necessary.

Apologies for the inconvience.

Hi, I’m hitting the same issue as the original poster. I’m using Unity 6 and version 2.0.4 of the VisionOS plugin, but I don’t see any option for 'IL2CPP Large Exe Workaround`. Has this been removed?

It is under XR Plugin Management > VisionOS