UE5 - Building shipping package on Mac M1 for Intel architecture

Hi,
similarly to the other thread I created for UE4 (which at the end works), I’m now creating this thread for UE5, as I’ve upgraded my project and I cannot find a way to package for Intel Architecture on M1 chip.

I migrated my project to UE5, and building shipping on windows and linux worked fine. I’m stuck on Mac as it is always creating a ARM64 executable.

I tried the following, incrementally.

  1. Start a new shell with arch x86_64:
    $env /usr/bin/arch -x86_64 /bin/zsh --login

  2. Set valid architectures in environment:

    export ARCHS=x86_64
    export VALID_ARCHS=x86_64

  3. Pass the -architecture flag to the build command:

-architecture=x86_64

My current build command is:

/Users/luke/5.1.1-release/Engine/Build/BatchFiles/RunUAT.command BuildCookRun -project=“/Users/luke/PSUnreal511/PSUnreal.uproject” -nop4 -Prereqs -package -target=PSUnrealClient -clientconfig=Shipping -utf8output -platform=Mac -architecture=x86_64 -targetplatform=Mac -build -cook -allmaps -pak -stage -archive -archivedirectory=“/Users/luke/temp/PSUnreal_Ship”

  1. Modify the Unreal Engine Xcode Settings and my project Xcode settings to have only Intel 64 architecture listed as available target platforms.

With all of the above, I still get an M1 executable for my project. I verify that with “file” command.

UnrealEditor is actually a x86_64:

luke@Lucas-Mac-mini Scripts % file ~/5.1.1-release/Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor
/Users/luke/5.1.1-release/Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor: Mach-O 64-bit executable x86_64

But my project is arm64:

luke@Lucas-Mac-mini Scripts % file ~/temp/PSUnreal_Ship/MacClient/PSUnrealClient.app/Contents/MacOS/PSUnrealClient
/Users/luke/temp/PSUnreal_Ship/MacClient/PSUnrealClient.app/Contents/MacOS/PSUnrealClient: Mach-O 64-bit executable arm64

In the logs I see this:

********** BUILD COMMAND STARTED **********
Building PSUnrealClientEditor as x86_64 (arm64 not currently supported)
Building UnrealHeaderTool as arm64 for host
Building UnrealHeaderTool as arm64 for host
Building ShaderCompileWorker as arm64 for host
Building UnrealPak as arm64 for host
Building PSUnrealClient as arm64 for local non-distribution

As you can see the last line says it is building arm64.

then it starts to rebuild the whole engine

Building 1548 actions with 1 process…
[1/1548] Link UnrealEditor-Core.dylib

then it compiles my project, but on the log I see it’s passing the -architecture=arm64 which I didn’t specify.

Does anyone know how to control this?

There is definitely a bug in the packager, the workaround I found is the following:

  1. run the packaging as usual, even if that creates a M1 executable
  2. check in the log the commands used by Automation Tool and pick the one where it’s compiling your project and execute again only that step with -architecture=x86_64
  3. run the packaging command again without the “-build” piece, so the packager will use the executable you created.

In my case these are the commands for step 2:

/Users/luke/5.1.1-release/Engine/Binaries/ThirdParty/DotNet/6.0.302/mac-x64/dotnet “/Users/luke/5.1.1-release/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll” PSUnrealClient Mac Shipping -Project=/Users/luke/PSUnreal511/PSUnreal.uproject /Users/luke/PSUnreal511/PSUnreal.uproject -NoUBTMakefiles -remoteini=“/Users/luke/PSUnreal511” -skipdeploy -architecture=x86_64 -Manifest=/Users/luke/5.1.1-release/Engine/Intermediate/Build/Manifest.xml -NoHotReload -log=“/Users/luke/Library/Logs/Unreal Engine/LocalBuildLogs/UBT-PSUnrealClient-Mac-Shipping.txt”

and for step 3:

/Users/luke/5.1.1-release/Engine/Build/BatchFiles/RunUAT.command BuildCookRun -archive -archivedirectory=/Users/luke/temp/PSUnreal_Ship -noP4 -project=/Users/luke/PSUnreal511/PSUnreal.uproject -cook -stage -package -pak -prereqs -nodebuginfo -platform=Mac -targetplatform=Mac -architecture=x86_64 -target=PSUnrealClient -clientconfig=Shipping -utf8output

1 Like

I tried to open the executable on a mac with an intel core i5 processor, I created my project on a mac m1 chip, but I can’t open it, a “cannot open the application” message appears, even after changing the architecture of the executable, any recommendations?

-specifiedarchitecture=x86_64
or:
-specifiedarchitecture=arm64
or:
-specifiedarchitecture=arm64+x86_64

Do you say that because you tried it, or because you think it should work? Because in my case that’s not working.

Apple’s chip build does not run on an Intel chip. Therefore, the two architectures must be built separately… Eg Game client target build/cook/package:

/...../UnrealEngine/Engine/Build/BatchFiles/RunUAT.command BuildCookRun -project=/.../MyProject/MyProyect.uproject -platform=Mac -client - clientconfig=Shipping -specifiedarchitecture=arm64+x86_64 -noP4 -nodebuginfo -allmaps -utf8output -build -nocomplieeditor -SkipCookingEditorContent -pak -package -stage -stagingdirectory=/..../Myproject/Package