Qt for iOS

Qt iOS 端口允許在 iOS 設備中運行 Qt 應用程序,譬如 iphone、ipad 和 iPod Touch。

支持的配置

支持下列配置。

目標平颱 體係結構 構建環境 注意事項
iOS 14, 15, 16, 17 armv8 ( arm64 ) Xcode 15 (iOS 17 SDK)
tvOS 12, tvOS 13 armv8 ( arm64 ) Xcode 11 (tvOS 13 SDK) 技術預覽
watchOS 5, watchOS 6 armv7k Xcode 11 (watchOS 6 SDK) 技術預覽。無 UI。
自動化測試使用的目標設備
設備 OS 版本 體係結構 形成因素
iPhone 12 iOS 16 armv8 (arm64) 移動
iPhone 11 iOS 16 armv8 (arm64) 移動
iPad Pro 第 3 代 iOS 15 armv8 (arm64) 數位闆
iPad 第 6 代 iOS 14 armv8 (arm64) 數位闆

快速入門

Development and deployment is done using Xcode. The supported workflow is to maintain a .pro file based project, which generates an Xcode project. Building and deploying can be done using either Xcode or Qt Creator. We will look at that in more detail in the next section.

The minimum deployment target for Qt applications is specified in 支持平颱 .

設置開發環境

可以下載 Qt 5 安裝程序從 下載 頁麵。更多信息,見 Qt 快速入門 .

安裝 Qt 前,首先需要安裝 Xcode。可以找到它在 Mac App Store here .

注意: As recommended by Apple, you should always use the latest Xcode version when building your applications for the App Store. In practice this means you also need the latest version of macOS to develop apps with Qt, due to Xcode's system requirements.

For running Qt applications on your Mac or in the simulator that comes with Xcode, this is all you need. However, for running applications on a mobile device and/or publishing your applications in the App Store, you must join the Apple 開發者程序 , and set up developer certificates and provisioning profiles. The easiest solution is to use a profile that takes any App ID (a * ).

Before building any Qt applications, you should test that Xcode is set up correctly, for example, by running one of the standard Xcode application templates on your device.

從命令行構建應用程序

As mentioned previously, the development workflow consists of maintaining a normal .pro file project and exporting it to Xcode.

Here is how to build a project with Xcode:

  • run qmake (if you have not done so previously)
  • open the resulting .xcodeproj 文件在 Xcode
  • 在 Xcode 構建應用程序

Note that you must re-import the project if its setup changes, for example, when adding or removing source files.

采用 Qt Creator 構建應用程序

You can find information on how to set up and run Apple mobile device applications in Qt Creator's manual:

As mentioned previously, you must have Xcode installed.

在 Qt 應用程序中使用 Objective-C 代碼

Clang, the compiler used for applications on Apple Platforms, allows mixing C++ and Objective-C code. To enable this mode, suffix your source files with .mm , and add them to OBJECTIVE_SOURCES 而不是 SOURCES .pro file. This makes it possible to use frameworks from Apple's Developer Library in Qt applications. Most useful is perhaps the possibility for adding In-App Purchasing with the StoreKit framework.

iOS 範例

In Qt Creator, tested examples on iOS can be looked up. Use the ios keyword to search for examples in the Qt Creator Welcome mode. Note that some examples may have limited functionality.

已知工作於 iOS 設備的範例列錶,拜訪 Qt for iOS 範例 .

下列主題提供瞭關於 Qt for iOS 的更多細節: