Qt / QMake iOS Set Target, Device, other XCode settings
ios, qmake, qt
Solution
I could not find this documented anywhere, but I figured it out.
In your qmake (pro or pri file) add these lines:
# Set "Target"
QMAKE_IOS_DEPLOYMENT_TARGET = 5.0
# Set "Devices" (2=iPad Only)
QMAKE_IOS_TARGETED_DEVICE_FAMILY = 2
Note for devices: 1=iPhone, 2=iPad, 1,2=Universal.
If you need to change other XCode project settings here's how you can:
After a build in Qt for iOS look at the "Compile Output" tab. You will find a list of "export VARIBALE=some_value" entries. To change one of these XCode build settings, simply use QMAKE_IOS_VARIABLE_NAME = my_value in your qmake.
For more info on these environmental varibles, check this out: Xcode Build Setting Reference
-- UPDATE --
I was wrong about the last part. You can't set all the XCode variables quite like that. If you output QMAKESPEC, however, you will get the path where you can find a qmake.conf file which will display some of these undocumented variables. Do so like this in your pro / pri:
message( $$QMAKESPEC )
That path will appear in the Qt console "General" tab when you build the project.
Here's an extended version I'm now using, with some logic for setting the build architectures:
greaterThan( QT_MAJOR_VERSION, 5 ){
DEFINES += QT_VER_5_4_OR_NEWER
}
else:equals( QT_MAJOR_VERSION, 5 ) &&
greaterThan( QT_MINOR_VERSION, 3 ){
DEFINES += QT_VER_5_4_OR_NEWER
}
contains(DEFINES, QT_VER_5_4_OR_NEWER){
DEFINES += SUPPORT_64_BIT_IOS
message( "SUPPORT_64_BIT_IOS" )
}
contains(DEFINES, SUPPORT_64_BIT_IOS) {
iosArchitectures="armv7 arm64"
iosTarget=5.1.1
}
else{
iosArchitectures=armv7
iosTarget=5.0
}
# Set "Architectures"
QMAKE_IOS_DEVICE_ARCHS = $$iosArchitectures
# Set "Target"
QMAKE_IOS_DEPLOYMENT_TARGET = $$iosTarget
# Set "Devices" (1=iPhone, 2=iPad, 1,2=Universal)
QMAKE_IOS_TARGETED_DEVICE_FAMILY = 2
Problem
Qt for iOS creates an XCode project when you execute a build. How does one dictate the XCode project settings from Qt to set a "target" (minimum iOS version) and "device" (Universal/iPhone/iPad), as found on the "General" tab in XCode when this project is opened?