I’m trying to confirm if there’s a problem on my end, or if what I’m trying to do is not possible – it seems like others are able to use the IL2CPP scripting backend on M1 macs without issue. All Unity versions spanning 2021 to 2023 show the same issue for me.
Environment is 2020 MacBook Pro, with Xcode 14.3 (14E222b), Ventura 13.2.1 (22D68), and Unity 2022.2.13f installed via UnityHub.
I’m much more comfortable in Linux despite using a Mac for several years now, but AFAICT I can build C++ sources without issue and all the usual tools are on my PATH.
/Applications/Xcode.app/Contents/Developer```
Every time I attempt a build in the editor, the embedded il2cpp call fails (per editor log):
Starting: /Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/bee_backend --dont-print-to-structured-log --ipc --dagfile=“Library/Bee/Playerdbbd0d9a.dag” --profile=“Library/Bee/backend1.traceevents” Player
WorkingDir: /Users/anthonyr/wkspaces/arm64-macos-il2cpp
[ ] Require frontend run. Library/Bee/Playerdbbd0d9a.dag couldn’t be loaded
Starting: /Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/Tools/netcorerun/netcorerun “/Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport/MacStandalonePlayerBuildProgram.exe” “/Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport/Bee:/Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/Tools/BuildPipeline” “Library/Bee/Playerdbbd0d9a.dag.json” “Library/Bee/Playerdbbd0d9a-inputdata.json” “Library/Bee/buildprogram0.traceevents”
WorkingDir: /Users/anthonyr/wkspaces/arm64-macos-il2cpp
ExitCode: 4 Duration: 0s108ms
ExitCode: 1 Duration: 0s830ms
Internal build system error. BuildProgram exited with code 1.
error: Could not set up a toolchain for Architecture x64. Make sure you have the right build tools installed for il2cpp builds. Details:
C++ code builder is unable to build C++ code. Mac builds are not supported on this platform.
The same failure occurs when generating an Xcode project (and building it with xcodebuild -project GameAssembly.xcodeproj):
/bin/sh -c /Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/GameAssembly.build/Script-251A4AC2ACF5885CBBC71E62.sh
/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp --compile-cpp --platform=MacOSX --architecture=x64 --outputpath=GameAssembly.dylib --libil2cpp-static --baselib-directory=/Applications/Unity/Hub/Editor/2022.2.13f1-arm64/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport --incremental-g-c-time-slice=3 --configuration=Release --dotnetprofile=unityaot-macos --profiler-report --profiler-output-file=/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Library/Bee/artifacts/il2cpp_conv_6972.traceevents --print-command-line --data-folder=/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Library/Bee/artifacts/MacStandalonePlayerBuildProgram/il2cppOutput/data --generatedcppdir=Il2CppOutputProject/Source/il2cppOutput --architecture=x64 --outputpath=/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/x64/GameAssembly.dylib --cachedirectory=/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/artifacts/x64 --configuration=Release
Starting: /Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/Il2CppOutputProject/IL2CPP/build/deploy/bee_backend/mac-arm64/bee_backend --profile=“/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/artifacts/x64/buildstate/backend_profiler0.traceevents” --beedriver-listener --dagfile=“/Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/artifacts/x64/buildstate/bee.dag” --continue-on-failure FinalProgram
WorkingDir: /Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/artifacts/x64/buildstate
ExitCode: 4 Duration: 0s182ms
ExitCode: 1 Duration: 0s0ms
Build failed with 0 successful nodes and 0 failed ones
Error: Internal build system error. BuildProgram exited with code 1.
Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: C++ code builder is unable to build C++ code. Mac builds are not supported on this platform.
If I intercept bee_backend and add --spammy-verbose, I see this:
[D] /Users/anthonyr/wkspaces/arm64-macos-il2cpp/Builds/build/GameAssembly.build/Release/artifacts/arm64/buildstate/bee.dag: mmap failed
Which could be normal if the exit 4 thing is expected, I'm not sure.
It seems like I'm missing or doing something dumb on my end, but I've tried debug builds with different switches, release builds, Intel 64-bit only builds, Apple-silicon only builds, mixed architecture, and literally nothing works with IL2CPP for me yet. The project above was a vanilla sample project generated by Unity (the one change being Mono-to-IL2CPP).
Mono builds are working for me, so it's not necessarily a blocker, but I'm trying to understand what's going wrong, since everything I read suggests installing Xcode makes it "Just Work". I'm able to dig much further, but I'm looking for some indication of where the problem lies.