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
若要建立如官方版本的 Xcode 專案,必須使用位於 misc/dist/ios_xcode 的樣板。發行版與偵錯版的函式庫應分別放入 libgodot.ios.release.xcframework 及 libgodot.ios.debug.xcframework。你可以在*最後*一次用於建置匯出範本的 SCons 指令中加上 generate_bundle=yes 選項,自動完成這個流程(以便包含所有二進位檔)。
MoltenVK 靜態 .xcframework 資料夾建立完成後,也必須放入 ios_xcode 資料夾內。在 iOS 上 MoltenVK 必須是靜態連結,沒有像 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 後再試一次。