Unity as a Library – iOS Debug Build Fails with ARM64 branch out of range Linker Error

Hi everyone,

I’m integrating Unity 2022.3.38f1 (URP, mid quality) as a library into my native iOS app.
Everything works fine when I build for Release, but when I try to make a Debug build, Xcode fails with this linker error:

B(l) ARM64 branch out of range (134305020 max is +/-128MB): from _ReversePInvokeWrapper_NativeLogRedirector_HandleWrite_m4232D60D7848A637DE497B24D870B534953A39E0 (0x018BDBD0) to __Unwind_Resume@0x00000000 (0x098D3144) in ‘_ReversePInvokeWrapper_NativeLogRedirector_HandleWrite_m4232D60D7848A637DE497B24D870B534953A39E0’

Context:

  • Unity is embedded as a library into a native iOS app.
  • Build configuration: Debug + IL2CPP ;
  • Happens only in Debug, not Release.
  • We use asset bundles and some native plugins.

Tried So Far:

  • Stripping Engine Code: false
  • Managed Stripping Level: Medium
  • IL2CPP Code Generation: Faster runtime
  • Still getting the same linker error.

This issue is not happening in android build.
Is there a recommended way to fix or work around this error in Unity as a Library setups?

Any tips to prevent this linker overflow or reduce symbol size safely for Debug builds?

Thanks in advance!

Hi,
can you please try to build with Smaller Size for IL2CPP Code Generation option ?

Hi,
I heard using Smaller size can lead to: slower performance at runtime.
So is it a good option ?

Impossible to say without testing your specific project. In some cases smaller code may even lead to better overall performance.
On mobiles optimizing for size is a good starting point, we are even thinking of changing the default for Android and iOS.