XCode can not build UnityWebRequest.o

Added IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND to xcodebuild and the issue seems to be gone for now.
For those who are building via xcodebuild, the command would look like this:

xcodebuild -workspace Unity-iPhone.xcworkspace \
...
GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1' \
...
-archivePath build.xcarchive archive

To others needing to get this working in Unity Cloud Build: I got this working by creating a file called Gymfile in Assets\ucb with the contents :

xcargs 'GCC_PREPROCESSOR_DEFINITIONS="$GCC_PREPROCESSOR_DEFINITIONS IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1"'

And a file called ucb_xcode_fastlane.json in Assets with the contents :

{
"gymfile": "Assets/ucb/Gymfile"
}

There was no need to touch any settings in the cloud build settings

I cannot get it to work. It seems like the flag got passed fine, but it’s not being considered by the build properly or smth

ld: B/BL out of range 182887748 (max +/-128MB) to ‘__ZN3Geo8GeoArrayIPKN9Enlighten13MaterialGuids12InstanceInfoEE11SetCapacityEi’

clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is the command
xcodebuild -project Unity-iPhone.xcodeproj GCC_PREPROCESSOR_DEFINITIONS=‘IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1’ -archivePath build.xcarchive archive -scheme “Unity-iPhone”

Unity 2023.1.15f1

@JoshPeterson we wanted to bump this thread. We started seeing this exact issue with the macOS Sonoma and Xcode 15 upgrade on our build farm. The builds were working just fine yesterday, and post the upgrades the builds now fail with this issue.

We’re currently on 2022.3.11f1 and are seeing the following:

d: B/BL out of range 144489060 (max +/-128MB) to '__ZN3Geo8GeoArrayIPKN9Enlighten13MaterialGuids12InstanceInfoEE11SetCapacityEi'

The workaround above does not work, however if you add -ld64 to the other linker flags on the Unity target and framework allows it to build.

Another reference: Xcode 15 B/BL out of range Error D… | Apple Developer Forums

Best regards

I have the same issue. This workaround doesn’t work anymore for the Unity 2022.

I’ve tried solution with -ld64 and didn’t work either :frowning:

What version of xcode are you using? Have you tried xcode15? I had this problem on xcode14, but it disappeared after upgrading to xcode15

I have the same issue and adding “-ld64” didn’t help.

B/BL out of range 135199396 (max +/- 128MB) from 0x00004024 ('+[UnityURLRequest requestForTask:]...

Xcode 15.2 (newest)
MacOS 14.3 (newest)
Unity 2023.2.8f (newest)
Total expected app size after building: 30-40 MB (very small)

I narrowed it down to “Data” folder not being able to be baked into UnityFramework in 2023.2.8f anymore if you follow this tutorial: uaal-example/docs/ios.md at master · Unity-Technologies/uaal-example · GitHub

It was working still in 2023.1.x and maybe also 2023.2.0f and 2023.2.4f.

Changing target/scheme to default Unity-iPhone (where the Data folder is not a part of UnityFramework) makes it build for me, but this way it’s not cleanly (or perhaps at all) possible to add my Swift files of my native app, so it’s not a solution.

Anyone knows anything?

Try changing il2cpp configuration to smaller code in Player Settings.

Thanks, you mean switching “Project Settings > Player > Android > Other Settings > IL2CPP Code Generation > Faster runtime” to “Faster (smaller) builds”?

If so, I’d rather have the default “faster runtime”.

I opened a bug report for this, because the above build error means the official Unity/iOS tutorial doesn’t work: uaal-example/docs/ios.md at master · Unity-Technologies/uaal-example · GitHub and Apple developer forum says it’s most likely caused by third party tools (Unity) “generating incorrect Mach-O object files” here: ld: Assertion failed: (resultIndex… | Apple Developer Forums

Can you let me know the bug report number? I’d like to follow up on this.

Sure, IN-67789.

I will be trying to move the “Data” folder to my native app to fix this as a workaround. It might work but I didn’t try yet.

1 Like

As soon as we upgraded to unity 2022 LTS, started to get a similar issue, looks like production and development builds (without script debugging) work, however, having the script debugging enabled non of the workarounds resolved the “branch out of range” issue.

Unity 2022.3.20f

In my case, I solved it by deleting the Library folder, deleting the csproj files, and switching platforms.
I hope this information is good for you.

2022.3.10f1
xcode 14.3.1

Just an update for anyone having the same issue:

  1. Moving the “Data” folder to the native iOS app didn’t resolve “B/BL out of range” issue.
  2. Unity closed my bug report without resolution because they couldn’t reproduce it.
  3. However, I noticed there are similar issues in their bug tracker already and the second one is especially relevant, but it got “WON’T FIX” status, which I think is a mistake:

What helped was switching from “faster runtime” to “smaller builds” in IL2CPP, but I’m observing significant overheating on iPhone and like 25-50% downgrade in performance compared to the same class of Android phone.

So, the issue is still there and I consider this to be a workaround.

1 Like

We’re now running into the same issue after upgrading from Unity 2021.3.29f1 to Unity 2022.3.21f1 (funnily enough only for release builds, not development builds).

As suggested by Josh, activating the workaround works for us, even though I’m a bit hesitant to release version that will have worse stack traces. The file can be found here:

  • Unity 2021.3: BuildFolder/Libraries/libil2cpp/include/os/c-api/il2cpp-config-platforms.h
  • Unity 2022.3: BuildFolder/Il2CppOutputProject/IL2CPP/libil2cpp/os/c-api/il2cpp-config-platforms.h

9744418--1394296--EnableLargeExecutableWorkaround.png

1 Like

how is this still an issue. It’s been 3 years. There is no good way to export to macOS…either I ruin the performance or ruin the stack trace.

Hmmm same problem here. I’ve tried the above WORKAROUND 1 fix and hasn’t helped.

I found that adding GCC_PREPROCESSOR_DEFINITIONS IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1 to xcodebuild didn‘t work for me,but I found a workaround to chang this symbol.
You can use sed -i -e to change the specific line in the il2cpp-config-platforms.h .
So for me , my Unity version is 2022.3 , so I can find this file from Il2CppOutputProject/IL2CPP/libil2cpp/os/c-api/ in the build folder , and change the 69 line .

so the command would look like this:

IOS_PROJECT_PATH="You output xcode project folder"
sed -i '' '69s/.*/#define IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND 1/' ${IOS_PROJECT_PATH}Il2CppOutputProject/IL2CPP/libil2cpp/os/c-api/il2cpp-config-platforms.h

xcodebuild -workspace Unity-iPhone.xcworkspace \
...
...
-archivePath build.xcarchive archive