Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I use BuildPipeline to build for M1 Mac?

Discussion in 'Scripting' started by highlyinteractive, Jul 22, 2021.

  1. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    116
    I'm trying to use the build pipeline to automate builds for different platforms, but there don't seem to be options for platform architecture. When using
    BuildPipeline.BuildPlayer
    I can only specify the target as
    BuildTarget.StandaloneOSX
    .

    How do I specify platform architecture?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    As far as I understand, the M1 Macs run MacOSX. Is this not the case?
     
  3. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    116
    Not exactly. If you look in Build Settings, you can select Intel 64-bit, Apple Silicon, or both.

    I'd like to know how to set this in code with BuildPipeline
     
  4. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    Last edited: Jul 22, 2021
    highlyinteractive likes this.
  5. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    116
    Thanks Mauri, that second link was what I needed
     
  6. chris_dev91

    chris_dev91

    Joined:
    Nov 23, 2016
    Posts:
    1
    If I understand this right this line will set the settings in the editor Build Settings only
    Code (CSharp):
    1. UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64ARM64;
    In my case, I'm looking for a way to build for OSX intel 64 + apple silicon with
    Code (CSharp):
    1.   BuildPipeline.BuildPlayer(scenes, targetDir, BuildTarget.StandaloneOSX, buildOptions);
    Is there any way to do this ?
     
  7. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    77
    This is me (one year later) wondering the exact same thing...

    The lack of a BuildTarget for Standalonex64ARM64 makes it impossible to reliably build for anything else than Intel64 when calling BuildPipeline.BuildPlayer().

    It could also be made possible by letting us specify a MacOSArchitecture in the BuildPlayerOptions.
     
    Last edited: Aug 29, 2023
  8. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    200
    Did you happen to get this figured out? I'm also trying to understand what we are supposed to be doing. Why is there no documentation on this? Very frustrating :(

    Edit: I may have figured it out. Haven't tested this yet, but I think this is whats going on.

    When you look at the tooltip for BuidlTarget.StandaloneOSX (which is now the ONLY non-deprecated OSX option), it says "Build a macOS standalone (Intel 64-bit)". I'm pretty sure this is wrong, and that behind the scenes its actually checking for this value to decide what to build:

    Code (CSharp):
    1. UnityEditor.OSXStandalone.UserBuildSettings.architecture
    That can be set to either x64, ARM64, or x64ARM64. I'm assuming x64ARM64 is equivalent to the option you get in File -> BuildSettings to build for both architectures.

    Used info from this thread:
    https://forum.unity.com/threads/headless-builds-targeting-apple-silicon.1085177/#post-6993635

    But I didn't know Apple Silicon uses ARM. I don't have a Mac and am not familiar with these sort of things. Kind of frustrating that its named "Intel" and "Apple Silicon" in File -> BuildSettings, but then x64 and ARM64 in the hidden setting that no one knows about, and that the BuildTarget has a wrong tooltip. Please fix, Unity!
     
    Last edited: Oct 24, 2023