Up to date

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

Linux上のiOS用のクロスコンパイル

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.

免責事項

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.

必要条件

  • 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 、 ソースから構築する必要があります。そのための手順を以下に説明します。

    • For newer versions you should download xar and pbzx.

    • 「darling-dmg」を構築するには、fuse、icu、openssl、zlib、bzip2というライブラリの開発パッケージが必要です。

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

  • cctools-port 必要なビルドツール。ビルドの手順は非常に独特であり、以下に説明します。

    • これには、automake、autogen、libtoolなどの追加の依存関係もあります。

環境のコンフィグ

darling-dmg

マシン上のリポジトリのクローンを作成します:

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

それを構築します:

$ 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 ../..

SDKの準備

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.

iOS SDK を抽出する:

$ # 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

SDKをパックする:

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

ツールチェーン

ビルド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

ツールをより良い場所にコピーします。ビルド用のSConsスクリプトは、ツールチェーンバイナリに指定するディレクトリ内の usr/bin の下に置かれるので、次のコマンドに似たサブディレクトリにコピーする必要があります:

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

iOSツールチェーンバイナリが /home/user/iostoolchain/usr/bin にあるはずです。

iPhone用ゴドットのコンパイル

上記のステップを完了したら、ビルドされたツールチェーンとiPhoneOS SDKディレクトリーという2つのものを環境に残しておく必要があります。これらはSConsのbuildコマンドにパスを指定する必要があるため、任意の場所に置くことができます。

iPhoneプラットフォームを検出するには、 OSXCROSS_IOS 環境変数を何かに定義する必要があります。

$ export OSXCROSS_IOS=anything

これで、標準的なGodotの方法のようにSConsを使ってiPhone用にコンパイルでき、正しいパスを提供するためのいくつかの引数を追加することができます:

$ 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-"