Published
- 3 min read
Compile UE project with console command line on MacOS
Sometimes we want to migrate our UE c++ project from windows to MacOS , two platforms have different building frameworks, we need make some adjustments accordingly…
- windows build UE project with MSBuild
- MacOS build UE project with Xcode, especially for iOS, it\’92s difficult to sign the app and upload it to apple store without Xcode…
1, Find where is your Unreal Engine root folder
Find where is your Unreal Engine root folder (where you installed unreal engine, choose the one you preferred if you have multiple versions)
for instance, my Unreal engine root folder is :
/Volumes/UE5/UnrealEngine
2 , Generate Xcode project for UE project (optional )
After coping UE project from windows , there is only visual studio project (*.sln , or cmake), we would like to have a Xcode project (*.xcworkspace)
open a console terminal, and change directory to your UE project root folder:
<UnrealEngine root folder>/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh -project=<Your UE project folder path>/ <Your UE project name>.uproject -game
About the [-game] please reference here
3, Build UE project with Clang toolchain
If our UE project contains c++ module , The UnrealEditor will not be able to open the project until we successfully compile the C++ code.
Try to compile UE project with this console command :
<UnrealEngine root folder>/Engine/Build/BatchFiles/Mac/Build.sh -Target="<Your UE project>Editor Mac Development" -project="<Your UE project folder path>/ <Your UE project name>.uproject" -WaitMutex -architecture=x64
-architecture=x64 tells UE building framework that we are building this project with intel x64 cpu,
if you are on apple silicon, you should try replacing this with arm64, I don’t have silicon machine now , I haven’t tried this argument yet.
if you have compiled the UE project successfully, then congratulation, you can go ahead and open your UE project with UnrealEditor, otherwise you may need to fix the c++ code according the outputted log message from compiler.
4, Automation Shell script
I have made a simple shell script that automatically find UE project’s Editor target (*Editor.target.cs) and call compiling command:
#!/bin/sh
# Change this UE ROOT folder according to your environment and UE version
UE_FOLDER="/Volumes/UE5/UnrealEngine"
UEPRJROOT="$(dirname "$0")"
UEPRJROOT="$(realpath $UEPRJROOT)"
echo "\n"
echo ">>>>>>>>>> TOOTzoe.com UE5 utility script for MacOS <<<<<<<<<<<"
echo "++++++++========= Ver: 2025-04-10 ===++++++++++++++"
echo "Using UE Root Dir: $UE_FOLDER"
echo "Current uproject Dir: $UEPRJROOT"
echo "++++++++=============================++++++++++++++"
echo "\n"
UPRO_PATHNAME="$(ls $UEPRJROOT/*.uproject 2>/dev/null)"
if [ ! -f "$UPRO_PATHNAME" ]; then
echo "Error!! No uproject found! .... Terminated...."
sleep 999
exit 0
fi
if [[ "$1" == "gen" ]]; then
echo "::::::::::: Generate (type: game) .xcworkspace for $UPRO_PATHNAME ...."
sh "$UE_FOLDER"/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh -project="$UPRO_PATHNAME" -game
exit 0
fi
UPRO_BASENAME="$(BaseName $UPRO_PATHNAME .uproject)"
TARGETNAME=""$UPRO_BASENAME"Editor"
if [ ! -f "$UEPRJROOT/Source/"$TARGETNAME".Target.cs" ]; then
echo "Error!! No Module-target for Editor found! .... Terminated...."
sleep 999
exit 0
fi
echo "++++==== UE build "$UPRO_BASENAME"Editor Dlls for: $UPRO_PATHNAME, Target=$TARGETNAME ====++++"
echo "\n\n"
## Apple x64 (intel cpu)
sh "$UE_FOLDER"/Engine/Build/BatchFiles/Mac/Build.sh -Target="$TARGETNAME Mac Development" -project="$UPRO_PATHNAME" -WaitMutex -architecture=x64
## Apple silicon ??
#sh "$UE_FOLDER"/Engine/Build/BatchFiles/Mac/Build.sh -Target="$TARGETNAME Mac Development" -project="$UPRO_PATHNAME" -WaitMutex -architecture=arm64
######### UE5 build UnrealEditor from source code
# ./Engine/Build/BatchFiles/Mac/Build.sh UnrealEditor Mac Development
you can find the shell script Here. before run this shell script inside your UE root folder, please modify the UEROOT variable accordingly your environment.
※If your failed to run the script, please go to System Settings —> Privacy & Security —> Security —> section , check whether the script has sufficient permissions to run.
5, Generate Xcode workspace with shell script
For convenience, run above shell script with <gen> argument to generate Xcode workspace quickly:
./TOOT_UE5mac_build20250410.command gen
Tips:
The commented line:
<UnrealEngine root folder>/Engine/Build/BatchFiles/Mac/Build.sh UnrealEditor Mac Development
is for building Unreal Engine from source code, without open the whole Unreal Engine source code inside Xcode (saving system memory ), we can build UnrealEditor.app from this command line.
Related Video
Thank you for reading~