Qt for iOS

Qt's iOS port allows you to run Qt applications on iOS devices, such as iPhones, iPads, and iPod Touches.

Supported Configurations

The following configurations are supported.

Target PlatformArchitectureBuild Environment
iOS 14, 15, 16, 17armv8 (arm64)Xcode 15 (iOS 17 SDK)
Target Devices used in Automated Testing
DeviceOS VersionArchitectureForm Factor
iPhone 12iOS 16armv8 (arm64)Mobile
iPhone 11iOS 16armv8 (arm64)Mobile
iPad Pro, 3rd generationiOS 15armv8 (arm64)Tablet
iPad, 6th generationiOS 14armv8 (arm64)Tablet

Getting Started

Qt supports you in building, testing, and deploying applications for iOS. Qt applications are typically defined using the CMake or qmake build tools. Both tools can generate an .xcodeproj file that can then be loaded and built from the command line, or with Xcode. Qt Creator also directly supports building, running, debugging, and profiling CMake and qmake projects for iOS.

The minimum deployment target for Qt applications is specified in Supported Platforms.

Setting Up the Development Environment

You can download the Qt installers from the Downloads page. For more information, see Getting Started with Qt.

Before installing Qt, you first need to install Xcode. You will find it in the Mac App Store here.

Note: 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 Developer Program, 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.

Building Applications from the Command Line

Use CMake or qmake to define how to build your iOS application. Both CMake and qmake can generate an xcodeproj file, which can then be loaded and built from the command line.

Using CMake

The qt-cmake convenience script located in <Qt-dir>/<version>/ios/bin/ will take care of setting up the toolchain and correct architectures for you.

Using qt-cmake convenience script:

<Qt-dir>/<version>/ios/bin/qt-cmake <source-dir>

Using the generated xcodeproj file, you can either use Xcode to build your application or run xcodebuild from the command line. For a list of available targets and schemes for your application, run the following command:

xcodebuild -list -project <your-app>.xcodeproj

Then, run xcodebuild build, passing in your application details:

xcodebuild build -allowProvisioningUpdates -project <your-app>.xcodeproj -scheme <your-scheme> -configuration Debug -destination "generic/platform=iOS" -destination-timeout 1 ENABLE_ONLY_ACTIVE_RESOURCES=NO

Using qmake

First, define how to build the application using qmake. Then, use the generated xcodeproj file to build the application, either in Xcode or from the command line.

qmake <your-app>.pro

qmake creates a wrapper Makefile that in turns calls xcodebuild, so you can run make to build your application:

make -j8

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

Customizing Xcode project settings

The QMAKE_MAC_XCODE_SETTINGS qmake variable can be used to customize Xcode settings, for example:

development_team.name = DEVELOPMENT_TEAM
development_team.value = <your-team-id>
QMAKE_MAC_XCODE_SETTINGS += development_team

Other qmake variables are also useful:

QMAKE_TARGET_BUNDLE_PREFIX = com.<your-company>
QMAKE_BUNDLE = <your-app>

Building Applications with 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.

Running Applications in Xcode

The Xcode projects generated by qmake and CMake support running the application on both iOS devices and in the iOS simulator.

Note: As the default architecture of the Qt for iOS simulator libraries is x86_64, the application must run under Rosetta on Apple Silicon Macs. If the Rosetta-based run destinations are not listed in Xcode's run destination menu they can be enabled via the Product > Destination > Destination Architectures menu.

Using Objective-C Code in Qt Applications

Clang, the compiler used for applications on Apple Platforms, allows mixing C++ and Objective-C code. To enable this mode use the .mm extension for the relevant source files and add them to your project as usual.

With CMake:

target_sources(myapp PRIVATE objc_code.mm)

With qmake:

SOURCES += objc_code.mm

You can then use Objective-C frameworks from Apple's Developer Library in your Qt applications.

To expose functionality to the rest of your application, without having to rename all your source files, declare helper functions in a header, and implement the functionality in an Objective-C++ source file:

// objc_code.h
QString localizedHostName();

// objc_code.mm
#include <Foundation/NSHost.h>
QString localizedHostName()
    return QString::fromNSString(NSHost.currentHost.localizedName);

Examples for 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.

For a list of examples known to work on iOS devices, visit Qt for iOS Examples.

The following topics provide more details about Qt for iOS:

© 2024 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.