Up to date

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

為 iOS 進行編譯

也參考

這個頁面描述的是如何從源碼編譯 iOS 匯出範本二進位。如果你想要找的是匯出專案到 iOS,請閱讀 為 iOS 匯出

系統需求

  • Python 3.5+

  • 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.

  • 下載並依照 README 說明從「MoltenVK SDK <https://github.com/KhronosGroup/MoltenVK#fetching-moltenvk-source-code>」建置靜態「.xcframework」。

備註

若有安裝 Homebrew ,則可以通過下列指令來輕鬆安裝 SCons 與 yasm:

brew install scons

安裝 Homebrew 時,若還未有適用於 Xcode 的命令行工具,也會自動安裝。

若有安裝 Homebrew ,則可以通過下列指令來輕鬆安裝 SCons 與 yasm:

sudo port install scons

也參考

要獲取編譯所需的 Godot 源碼,請參閱 取得原始碼

有關配合 Godot 使用 SCons 的一般說明,請參考 建置系統簡介

編譯

Open a Terminal, go to the root folder of the engine source code and type the following to compile a debug build:

scons platform=ios target=template_debug generate_bundle=yes

To compile a release build:

scons platform=ios target=template_release generate_bundle=yes

Alternatively, you can run the following command for Xcode simulator libraries (optional):

scons platform=ios target=template_debug ios_simulator=yes arch=arm64
scons platform=ios target=template_debug ios_simulator=yes arch=x86_64 generate_bundle=yes

These simulator libraries cannot be used to run the exported project on the target device. Instead, they can be used to run the exported project directly on your Mac while still testing iOS platform-specific functionality.

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. This process can be automated by using the generate_bundle=yes option on the last SCons command used to build export templates (so that all binaries can be included).

The MoltenVK static .xcframework folder must also be placed in the ios_xcode folder once it has been created. MoltenVK is always statically linked on iOS; there is no dynamic linking option available, unlike macOS.

執行

若要在一台裝置或模擬器上執行,請依照下列指示: 為 iOS 匯出