Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
為 iOS 編譯
也參考
本頁說明如何從原始碼編譯 iOS 匯出範本二進位檔。如果你想要將專案匯出到 iOS,請參閱 為 iOS 匯出。
系統需求
SCons 4.4+ build system.
- Xcode。
請先啟動一次 Xcode 並安裝 iOS 支援。若已經啟動過 Xcode但需要安裝 iOS 支援,請前往 Xcode -> 設定... -> 平台。
前往 Xcode -> 設定... -> 位置 -> 命令列工具 並選擇一個已安裝的版本。即使已經有選擇,請重新選取一次。
下載並依照 README 說明,從 MoltenVK SDK 建置靜態
.xcframework。
編譯
開啟終端機,前往引擎原始碼的根目錄,並輸入下列指令以編譯偵錯版本:
scons platform=ios target=template_debug generate_bundle=yes
要編譯發行版本:
scons platform=ios target=template_release generate_bundle=yes
To create an Xcode project like in the official builds, you need to use the
template located in misc/dist/apple_embedded_xcode. The release and debug libraries
should be placed in libgodot.ios.debug.xcframework and
libgodot.ios.release.xcframework respectively. Camera module libraries
should be placed in libgodot_camera.ios.debug.xcframework and
libgodot_camera.ios.release.xcframework. 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
apple_embedded_xcode folder once it has been created. MoltenVK is always statically
linked on iOS; there is no dynamic linking option available, unlike macOS.
警告
The iOS simulator only supports the Compatibility renderer.
Apple Silicon Macs can run iOS apps natively, so you can run exported iOS projects directly on an Apple Silicon Mac without iOS simulator limitations.
執行
如需在裝置上執行,請依照這些指示操作: 為 iOS 匯出。
匯出的 iOS 專案可直接在 Apple Silicon 的 Mac 上執行。要在 Mac 執行匯出的 iOS 專案,請在 Xcode 開啟匯出的專案,並在 Run Destinations 下拉選單中選擇 My Mac。
疑難排解
致命錯誤:找不到 'cstdint' 檔案
如果在一開始就遇到這類編譯錯誤,通常是因為在更新 macOS 或 Xcode 後,Xcode 命令列工具需要修復:
./core/typedefs.h:45:10: fatal error: 'cstdint' file not found
45 | #include <cstdint>
| ^~~~~~~~~
執行以下兩個指令以重新安裝 Xcode 命令列工具(需要時輸入系統管理員密碼):
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
若仍無法解決,請從 Mac App Store 更新 Xcode 後再試一次。