summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-05-13 14:34:36 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-05-20 13:06:10 +0200
commita2255a3ab224099eaaf7c3ab37cd6e9c18aa5105 (patch)
tree5833472592d07cd4cec88294c23d26bf1263c1cc
parent25e21717defadf64999c0f4ac7cad9d78c99fc2b (diff)
CMake: Ensure creation of a unique iOS bundle identifier
Apple ties iOS application bundle identifiers to Apple accounts. When building against the device SDK, the bundle identifier must be unique, so that Xcode can register the id with the used developer account and create an appropriate provisioning profile for the used device. If it's not unique (was previously used on a machine with a different developer account), in the best case you get an error explaining that. In the worst case you get an error about automatic signing not being enabled (at least on the command line). When building an Xcode project for the first time on a fresh machine, the organization bundle identifier prefix might not be set. Opening a Qt example project on such a machine might result in generating the same bundle identifier, leading to the error described above. Warn project builders that they should either specify a prefix or an entire unique identifier. To ensure building still works in such a case, try to hash the team id if it is present and add it as an infix to the auto-generated bundle identifier. Note that simulator builds are not affected by id uniqueness because apps deployed to the simulator do not require a provisioning profile from Apple. Amends 4d838dae5a821e9e5f013ba1d5a494ece1b5180e [ChangeLog][iOS][CMake] The build system tries to create a unique bundle identifier based on the team id if no organization prefix can be retrieved from Xcode preferences. Pick-to: 6.2 6.3 Task-number: QTBUG-95838 Change-Id: I6ad10076751acf43064330a6e53d6c4e973ec362 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/corelib/Qt6CoreMacros.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 884afc599f..aaa80d55d5 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -946,6 +946,23 @@ function(_qt_internal_get_default_ios_bundle_identifier out_var)
_qt_internal_get_ios_bundle_identifier_prefix(prefix)
if(NOT prefix)
set(prefix "com.yourcompany")
+
+ # For a better out-of-the-box experience, try to create a unique prefix by appending
+ # the sha1 of the team id, if one is found.
+ _qt_internal_find_ios_development_team_id(team_id)
+ if(team_id)
+ string(SHA1 hash "${team_id}")
+ string(SUBSTRING "${hash}" 0 8 infix)
+ string(APPEND prefix ".${infix}")
+ else()
+ message(WARNING
+ "No organization bundle identifier prefix could be retrieved from Xcode "
+ "preferences. This can lead to code signing issues due to a non-unique bundle "
+ "identifier. Please set up an organization prefix by creating a new project within "
+ "Xcode, or consider providing a custom bundle identifier by specifying the "
+ "XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER property."
+ )
+ endif()
endif()
# Escape the prefix according to rfc 1034, it's important for code-signing. If an invalid