"Headless" builds targeting Apple Silicon

I am working on upgrading our project to 2020.3 (from 2019.4). While it seems that upgrading the project itself went just fine, I am running into some unclarities regarding building with a headless unity.

Specifically, we are working towards supporting native Apple Silicon builds. We have CI in place with Jenkins, which builds are project(s) through a headless unity. We are able to set our intended buildTarget and any other settings as we desire, but it seems there is not really a way for MacOS builds to specify the desired architecture. Looking at the Unity Manual OSXUniversal is (still) the only option available, which I assume isn’t changed from the previous versions and builds for Intel 64-bit.

So my question is: How, through code or command line arguments, can I target Apple Silicon and Intel 64-bit & Apple Silicon architectures?

You can set it via an editor script:

#if UNITY_EDITOR && UNITY_STANDALONE_OSX
UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64;
UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.ARM64;
UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64ARM64;
#endif

That said, Unity defaults to building x64 + ARM64 (universal, in other words).

1 Like

Ah, that’s great! Thanks!