How do you build from the command line on OSX?

There are a number of questions relating to how to build from the command line, for example Automated test results from command line - AnswerHub - Unreal Engine Forums, however, none of them appear to work on OSX.

Tok:Engine doug$ Build/BatchFiles/RunUAT.sh BuildCookRun -nop4 -project="/Users/doug/Documents/Unreal\ Projects/Hello/Hello.uproject" -stage -archive -archivedirectory="/tmp/hello" -package -targetplatform=Darwin

Running AutomationTool...

Setting up Mono
Compiling AutomationTool with xbuild
xbuild Source/Programs/AutomationTool/AutomationTool_Mono.csproj /p:Configuration=Development /p:Platform=AnyCPU /verbosity:quiet /nologo /p:TargetFrameworkProfile= /p:TargetFrameworkVersion=v4.5
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/Users/doug/dev/unreal/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Mac/lib/mono/2.0/mscorlib.dll' directory.
RunUAT ERROR: AutomationTool failed to compile.

Is my version of mono wrong (how would the Microsoft mscorlib.dll even possibly exist on osx?)? If so, what version do I need?

How do you do this on a mac?

Some people (How can I execute UE4Editor on the command line as a different user than what is logged in? - Programming & Scripting - Unreal Engine Forums) seem to invoke the UE4Editor directly, but that was for an old version of UE.

Edit: After installing the binaries, it still doesnā€™t work, but with a different error:

InternalUtils.SafeFileExists: SafeFileExists /Users/doug/Documents/Unreal/ Projects/Hello/Hello.uproject=False
InternalUtils.SafeFileExists: SafeFileExists /Users/doug/dev/unreal/UnrealEngine/Users/doug/Documents/Unreal/ Projects/Hello/Hello.uproject=False
InternalUtils.SafeFileExists: SafeFileExists /Users/doug/dev/unreal/UnrealEngine/Engine/Programs/AutomationTool/Saved/Rules/UATRules_BaseEngine_.dll=False
ProjectUtils.CompileAndLoadTargetsAssembly: Compiling targets DLL: /Users/doug/dev/unreal/UnrealEngine/Engine/Programs/AutomationTool/Saved/Rules/UATRules_BaseEngine_.dll
BuildCommand.Execute: ERROR: BUILD FAILED
Program.Main: ERROR: AutomationTool terminated with exception:
Program.Main: ERROR: Exception in AutomationTool: All branches must have the blank project /Samples/Sandbox/BlankProject
Stacktrace:   at AutomationTool.BranchInfo..ctor (System.Collections.Generic.List`1 InHostPlatforms) [0x00000] in <filename unknown>:0
  at BuildCookRun.get_ProjectPath () [0x00000] in <filename unknown>:0
  at BuildCookRun.ExecuteBuild () [0x00000] in <filename unknown>:0
  at BuildCommand.Execute () [0x00000] in <filename unknown>:0
Program.Main: ERROR: All branches must have the blank project /Samples/Sandbox/BlankProject
ProcessManager.KillAll: Trying to kill 0 spawned processes.
Program.Main: AutomationTool exiting with ExitCode=1
Domain_ProcessExit
ProcessManager.KillAll: Trying to kill 0 spawned processes.
RunUAT ERROR: AutomationTool was unable to run successfully.

Mono is an implementation of C# runtime and uses Windows convention for files extensions (.dll, .exe)

As for the problem youā€™re having, it seems that you didnā€™t run Setup.command after downloading the code from GitHub.

Iā€™d love to say that fixed it (and I suppose it didā€¦) but all it did was lead me onto another different errorā€¦

Try ā€œ/Users/doug/Documents/Unreal Projects/Hello/Hello.uprojectā€ instead of ā€œ/Users/doug/Documents/Unreal\ Projects/Hello/Hello.uprojectā€

UE4Editor: [2015.03.16-15.47.06:365][ 0]The game module ā€˜Helloā€™ does not appear to be up to date. This may happen after updating the engine.

ā€¦

ErrorReporter.Error: ERROR: AutomationTool error: No files found to deploy for /Users/doug/Documents/Unreal Projects/Hello/Binaries/Mac/Hello.app with wildcard * and exclusions

Any ideas?

It does actually work when I run with only -cook, which is awesome! ā€¦but I canā€™t actually generate an .app; it just creates an empty folder in /tmp/hello/MacNoEditor/

It looks like you didnā€™t build the editor, or your projectā€™s editor dylib.

ā€¦isnā€™t building the project what this command line tool is supposed to do?

At any rate, how do I build the projectā€™s editor dylib then?
I did just build the editor, an couple of hours ago:

Tok:Engine doug$ ls -l Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor
-rwxr-xr-x 1 doug staff 443208 16 Mar 22:11 Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor

No, this command line is for packaging the game

To build from command line you can use Build.sh script. Something like this:

cd /Users/doug/dev/unreal/UnrealEngine

./Engine/Build/BatchFiles/Mac/Build.sh HelloEditor Mac Development "/Users/doug/Documents/Unreal Projects/Hello/Hello.uproject"

The final solution to my original question is:

  1. Clone the source from github: Unreal Engine on GitHub

  2. Run Setup.sh to install all the binary components

  3. Build the project; GenerateProjectFiles.sh && xcodebuild -target "UE4Editor - Mac"

When that eventually finishes you are now ā€˜setupā€™ to run command line builds.

Then if you have a project in ~/dev/unreal/projects/HelloWorld, you can build it using:

./Engine/Build/BatchFiles/Mac/Build.sh HelloWorldEditor Mac Development ~/dev/unreal/projects/HelloWorld/HelloWorld.uproject
Obviously the exact target is not ā€˜HelloWorldEditorā€™ in all cases; but the build tool will list available build targets if itā€™s not; pick the appropriate one.

Thanks so much for you time! Finally got this working now.

Actually, you donā€™t need to build the editor in step 3 using xcodebuild and the Xcode project. You can do this:

./Engine/Build/BatchFiles/Mac/Build.sh UE4Editor Mac Development

Also, building HelloWorldEditor target will build the editor itself as well if needed. Itā€™s packaging (cooking, to be more precise), that you were trying to run earlier with RunUAT, that requires the editor to be already built.

1 Like