diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-17 11:21:01 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-17 21:30:34 +0200 |
commit | b5d833730e758c63cdaf48c584e069bb82e68e38 (patch) | |
tree | aa701548947e9784a51c292f845f69ee7e0be790 | |
parent | 3d2dc88850b6ba030238791dcd4a4ec44bb2479d (diff) |
CMake: Set a placeholder bundle version for iOS apps
Without a bundle version and short version string string, the
iOS simulator will refuse to launch the app.
Set a placeholder "0.0.1" version for both fields if they were not set
by the project. Allow opt-out via a QT_NO_SET_XCODE_BUNDLE_VERSION
variable.
Pick-to: 6.2
Fixes: QTBUG-95836
Task-number: QTBUG-95838
Change-Id: I3e959766c7fa13f23ad12882f8bd14cd45e7096c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index fe750f8585..941caa0927 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -715,6 +715,30 @@ function(_qt_internal_get_default_ios_bundle_identifier out_var) set("${out_var}" "${prefix}.\${PRODUCT_NAME:rfc1034identifier}" PARENT_SCOPE) endfunction() +function(_qt_internal_set_placeholder_apple_bundle_version target) + # If user hasn't provided neither a bundle version nor a bundle short version string for the + # app, set a placeholder value for both which will add them to the generated Info.plist file. + # This is required so that the app launches in the simulator (but apparently not for running + # on-device). + get_target_property(bundle_version "${target}" MACOSX_BUNDLE_BUNDLE_VERSION) + get_target_property(bundle_short_version "${target}" MACOSX_BUNDLE_SHORT_VERSION_STRING) + + if(NOT MACOSX_BUNDLE_BUNDLE_VERSION AND + NOT MACOSX_BUNDLE_SHORT_VERSION_STRING AND + NOT bundle_version AND + NOT bundle_short_version AND + NOT QT_NO_SET_XCODE_BUNDLE_VERSION + ) + set(bundle_version "0.0.1") + set(bundle_short_version "0.0.1") + set_target_properties("${target}" + PROPERTIES + MACOSX_BUNDLE_BUNDLE_VERSION "${bundle_version}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${bundle_short_version}" + ) + endif() +endfunction() + function(_qt_internal_finalize_ios_app target) # If user hasn't provided a development team id, try to find the first one specified # in the Xcode preferences. @@ -749,6 +773,8 @@ function(_qt_internal_finalize_ios_app target) "${bundle_id}") endif() endif() + + _qt_internal_set_placeholder_apple_bundle_version("${target}") endfunction() if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) |