Search Unity

Cannot build Unity 2020 projects using command-line on macOS with Xcode 10 or 11

Discussion in 'Getting Started' started by RichardTea, Mar 29, 2021.

  1. RichardTea

    RichardTea

    Joined:
    Jan 14, 2019
    Posts:
    7
    Unity 2020.3.1f1 has added support for M1 Native.
    Xcode 10 and 11 do not contain the M1 toolchain, and so the "universal" macOS builds cannot work.

    At the moment we cannot use Xcode 12, and even if we could we cannot ship an M1 native build yet for other reasons.

    I am able to build manually from the Editor by selecting the "Intel 64-bit" architecture in File > Build Settings, and this build appears to work.

    How do I make this same selection in my Build script?

    The 2020.3 documentation makes no mention of macOS M1 or Intel 64 builds.

    I have tried using "BuildPlayerOptions.target = BuildTarget.StandaloneOSXIntel64", which I found from the C# headers.

    However, this does not work and I still get the error "Unsupported target", implying my platform choice was ignored.
     
  2. RichardTea

    RichardTea

    Joined:
    Jan 14, 2019
    Posts:
    7
    It appears that there is an undocumented and completely hidden UnityEditor class to do this.

    My thanks to Tautvydas-Zilys, who appears to be the only person aware of its existence.

    Repeated here to try to get some more Google keyword hits for future users of Unity.

    This is apparently only available in an Editor script (MyProject/Assets/Editor/MyFile.cs)

    Code (CSharp):
    1. // Undocumented UnityEditor namespace
    2. // It is not visible in any of the managed assemblies, you will never, ever find this
    3. #if UNITY_EDITOR && UNITY_STANDALONE_OSX
    4. // Intel amd64:
    5. UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64;
    6. // Apple Silicon/M1 ARM64:
    7. UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.ARM64;
    8. // macOS Universal or Fat binary:
    9. UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64ARM64;
    10. #endif
    https://forum.unity.com/threads/clo...-silicon-dlls-failing-in-macos-build.1066970/
    https://forum.unity.com/threads/headless-builds-targeting-apple-silicon.1085177/
     
    Colin_MacLeod likes this.
  3. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Hi, I am facing the same problem. In which method are you calling those lines? Can you share the MyFile.cs class? Thank you!