Qt for iOS
Qt's iOS port allows you to run Qt applications on iOS devices, such as iPhones, iPads, and iPod Touches.
The following configurations are supported.
|Target Platform||Architecture||Build Environment||Notes|
|iOS 13, iOS 14, iOS 15||Xcode 12 (iOS 14 SDK), Xcode 13 (iOS 15 SDK)|
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.
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.
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.
While it's possible to use Makefiles or Ninja to build static libraries targeting iOS, you have to use the Xcode generator for executable applications or shared libraries.
You can choose to use the
qt-cmake convenience script located in
<Qt-dir>/<version>/ios/bin/ or use CMake directly from the command line. If you run CMake directly, you need to set the
CMAKE_OSX_ARCHITECTURES, and the Qt toolchain file with
qt-cmake convenience script will set these variables for you.
qt-cmake convencience script:
<Qt-dir>/<version>/ios/bin/qt-cmake <source-dir> -G Xcode
Using CMake directly:
cmake <source-dir> -G Xcode -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DCMAKE_OSX_SYSROOT="iphoneos" -DCMAKE_TOOLCHAIN_FILE="<Qt-dir>/<version>/ios/lib/cmake/Qt6/qt.toolchain.cmake"
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
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
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 -spec macx-ios-clang CONFIG+=debug CONFIG+=iphoneos CONFIG+=device CONFIG+=qml_debug QMAKE_MAC_XCODE_SETTINGS+=qteam qteam.name=DEVELOPMENT_TEAM qteam.value=<your-team-id> QMAKE_TARGET_BUNDLE_PREFIX+=com.<your-company> QMAKE_BUNDLE+=<your-app>
qmake creates a wrapper Makefile that in turns calls
xcodebuild, so you can run
make to build your application:
Note that you must re-import the project if its setup changes, for example, when adding or removing source files.
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.
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 instead of
SOURCES in the
.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.
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:
© 2022 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.