Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Compilation croisée pour iOS sur Linux

The procedure for this is somewhat complex and requires a lot of steps, but once you have the environment properly configured you can compile Godot for iOS anytime you want.

Avertissement

While it is possible to compile for iOS on a Linux environment, Apple is very restrictive about the tools to be used (especially hardware-wise), allowing pretty much only their products to be used for development. So this is not official. However, in 2010 Apple said they relaxed some of the App Store review guidelines to allow any tool to be used, as long as the resulting binary does not download any code, which means it should be OK to use the procedure described here and cross-compiling the binary.

Pré-requis

  • XCode with the iOS SDK (a dmg image, for newer versions a xip file is going to be downloaded.)

  • Clang >= 3.5 for your development machine installed and in the PATH. It has to be version >= 3.5 to target arm64 architecture.

  • Fuse for mounting and unmounting the dmg image.

  • darling-dmg, qui doit être construit à partir des sources. La procédure pour cela est expliquée ci-dessous.

    • For newer versions you should download xar and pbzx.

    • Pour construire darling-dmg, vous aurez besoin des paquets de développement des bibliothèques suivantes : fuse, icu, openssl, zlib, bzip2.

    • For building xar and pbzx you may want to follow this guide.

  • cctools-port pour les outils de construction nécessaires. La procédure de construction est assez particulière et est décrite ci-dessous.

    • Cela a également des dépendances supplémentaires : automake, autogen, libtool.

Configurer l'environnement

darling-dmg

Clonez le dépôt sur votre machine :

$ git clone https://github.com/darlinghq/darling-dmg.git

Construisez-le :

$ cd darling-dmg
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make -j 4  # The number is the amount of cores your processor has, for faster build
$ cd ../..

Préparation du SDK

Montez l'image XCode :

$ mkdir xcode
$ ./darling-dmg/build/darling-dmg /path/to/Xcode_7.1.1.dmg xcode
[...]
Everything looks OK, disk mounted

For newer versions you should extract the xip file:

$ mkdir xcode
$ xar -xf /path/to/Xcode_X.x.xip -C xcode
$ pbzx -n Content | cpio -i
[...]
######### Blocks

Note that for the commands below, you may need to replace the version (X.x) with whatever iOS SDK version you're using.

Extraire le SDK iOS :

$ # If you don't know your iPhone SDK version you can see the json file inside of Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ mkdir -p iPhoneSDK/iPhoneOSX.x.sdk
$ cp -r xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/* iPhoneSDK/iPhoneOSX.x.sdk
$ cp -r xcode/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/* iPhoneSDK/iPhoneOSX.x.sdk/usr/include/c++
$ fusermount -u xcode  # unmount the image

Empaquetez le SDK :

$ cd iPhoneSDK
$ tar -cf - * | xz -9 -c - > iPhoneOSX.x.sdk.tar.xz

Toolchain

Construire cctools :

$ git clone https://github.com/tpoechtrager/cctools-port.git
$ cd cctools-port/usage_examples/ios_toolchain
$ ./build.sh /path/iPhoneOSX.x.sdk.tar.xz arm64

Copiez les outils à un endroit plus approprié. Notez que les scripts SCons pour la construction regarderont à l'intérieur du répertoire usr/bin pour vous fournir les binaires de la chaîne d'outils, vous devez donc copier dans ce sous-répertoire, comme pour les commandes suivantes :

$ mkdir -p /home/user/iostoolchain/usr
$ cp -r target/bin /home/user/iostoolchain/usr/

Maintenant vous devez avoir les binaires de la chaîne d'outils iOS dans /home/user/iostoolchain/usr/bin.

Compilation de Godot pour iPhone

Une fois que vous avez effectué les étapes ci-dessous, vous devez conserver deux choses dans votre environnement : la chaîne d'outils construite et le répertoire SDK pour iPhoneOS. Ceux-ci peuvent rester n'importe-où ou vous voulez car vous devez fournir leurs chemins à la commande de construction SCons.

Pour que la plate-forme iPhone soit détectée, vous avez besoin de la variable d'environnement OSXCROSS_IOS définie à n'importe quoi.

$ export OSXCROSS_IOS=anything

Vous pouvez maintenant compiler pour iPhone en utilisant SCons comme la méthode standard de Godot, avec quelques arguments supplémentaires pour fournir les chemins corrects :

$ scons -j 4 platform=ios arch=arm64 target=template_release IOS_SDK_PATH="/path/to/iPhoneSDK" IOS_TOOLCHAIN_PATH="/path/to/iostoolchain" ios_triple="arm-apple-darwin11-"