Skip to content

Compiling for iOS

INFO

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

Requirements

  • Python 3.6+.

  • SCons 3.1.2+ build system.

  • Xcode.

    • Launch Xcode once and install iOS support. If you have already launched Xcode and need to install iOS support, go to Xcode -> Settings... -> Platforms.
    • Go to Xcode -> Settings... -> Locations -> Command Line Tools and select an installed version. Even if one is already selected, re-select it.

If you are building the master branch:

  • Download and follow README instructions to build a static .xcframework from the MoltenVK SDK.

INFO

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

shell
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:

shell
sudo port install scons

INFO

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

Open a Terminal, go to the root dir of the engine source code and type:

shell
$ scons p=ios target=template_debug

for a debug build, or:

shell
$ scons p=ios target=template_release

for a release build (check platform/ios/detect.py for the compiler flags used for each configuration).

Alternatively, you can run

shell
$ scons p=ios target=template_debug ios_simulator=yes arch=x86_64
$ scons p=ios target=template_debug ios_simulator=yes arch=arm64

for a Simulator libraries.

To create an Xcode project like in the official builds, you need to use the template located in misc/dist/ios_xcode. The release and debug libraries should be placed in libgodot.ios.debug.xcframework and libgodot.ios.release.xcframework respectively.

shell
$ cp -r misc/dist/ios_xcode .

$ cp libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a
$ lipo -create libgodot.ios.template_debug.arm64.simulator.a libgodot.ios.template_debug.x86_64.simulator.a -output ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a

$ cp libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a
$ lipo -create libgodot.ios.template_release.arm64.simulator.a libgodot.ios.template_release.x86_64.simulator.a -output ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a

The MoltenVK static .xcframework folder must also be placed in the ios_xcode folder once it has been created.

Run

To run on a device or simulator, follow these instructions: Exporting for iOS.