Compiling for macOS

Note

This page describes how to compile macOS editor and export template binaries from source. If you're looking to export your project to macOS instead, read Exporting for macOS.

Requirements

For compiling under macOS, the following is required:

Warning

If you are building the master branch, download and install the Vulkan SDK for macOS. This is required to compile Godot 4.x, as MoltenVK is used to translate Vulkan to Metal (macOS doesn't support Vulkan out of the box).

Note

If you have Homebrew installed, you can easily install SCons using the following command:

brew install scons

Installing Homebrew will also fetch the Command Line Tools for Xcode automatically if you don't have them already.

Similarly, if you have MacPorts installed, you can easily install SCons using the following command:

sudo port install scons

See also

To get the Godot source code for compiling, see Getting the source.

For a general overview of SCons usage for Godot, see Introduction to the buildsystem.

Compiling

Start a terminal, go to the root directory of the engine source code.

To compile for Intel (x86-64) powered Macs, use:

scons platform=macos arch=x86_64

To compile for Apple Silicon (ARM64) powered Macs, use:

scons platform=macos arch=arm64

To support both architectures in a single "Universal 2" binary, run the above two commands and then use lipo to bundle them together:

lipo -create bin/godot.macos.tools.x86_64 bin/godot.macos.tools.arm64 -output bin/godot.macos.tools.universal

If all goes well, the resulting binary executable will be placed in the bin/ subdirectory. This executable file contains the whole engine and runs without any dependencies. Executing it will bring up the project manager.

Note

If you want to use separate editor settings for your own Godot builds and official releases, you can enable Self-contained mode by creating a file called ._sc_ or _sc_ in the bin/ folder.

To create an .app bundle like in the official builds, you need to use the template located in misc/dist/macos_tools.app. Typically, for an optimized editor binary built with target=release_debug:

cp -r misc/dist/macos_tools.app ./Godot.app
mkdir -p Godot.app/Contents/MacOS
cp bin/godot.macos.opt.tools.universal Godot.app/Contents/MacOS/Godot
chmod +x Godot.app/Contents/MacOS/Godot

Note

If you are building the master branch, you also need to include support for the MoltenVK Vulkan portability library. By default, it will be linked statically from your installation of the Vulkan SDK for macOS. You can also choose to link it dynamically by passing use_volk=yes and including the dynamic library in your .app bundle:

mkdir -p Godot.app/Contents/Frameworks
cp <Vulkan SDK path>/macOS/lib/libMoltenVK.dylib Godot.app/Contents/Frameworks/libMoltenVK.dylib

Running a headless/server build

To run in headless mode which provides editor functionality to export projects in an automated manner, use the normal build:

scons