Qt for iOS - 从源代码构建

要从源代码构建Qt for iOS,需要安装了命令行工具的Xcode。您可以在终端中直接输入xcode-select --install 安装 Xcode 命令行工具,或者通过Homebrew 作为软件包进行安装。Qt 源代码可通过克隆代码库或下载源代码包来获取。

要进行 Qt 的交叉编译,您需要先构建一个主机版的 Qt。详情请参阅《Qt 的交叉编译》。

随后即可配置并构建 Qt。操作需在 Qt 根目录下进行:

> ./configure -platform macx-ios-clang -release -qt-host-path <path_to_host_qt_installation>

注意: 如果ninja 可执行文件可用,configure 始终会使用Ninja生成器和构建工具。Ninja 具有跨平台、功能丰富、性能优异等特点,建议在所有平台上使用。使用其他生成器可能有效,但不受官方支持。

有关其他 configure 选项,请参阅《Qt 配置选项》。

随后,只需运行cmake --build . --parallel 即可。

注意: 默认构建 将同时包含模拟器和设备库。若要针对单一目标进行构建,请在-sdk 命令中添加iphoneos 或iphonesimulator 参数。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.