diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-11-08 14:01:23 +0200 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2021-11-11 12:52:10 +0200 |
commit | 42ceea002f0c2830b4e3a2159e0e1e6e7fe3c6ee (patch) | |
tree | 499eb27cb71ba9efec4d727e1860ae245585a1d8 | |
parent | 8432c4716c712a2414c147d3e04ebcbe7d6b454f (diff) | |
download | qtconnectivity-42ceea002f0c2830b4e3a2159e0e1e6e7fe3c6ee.tar.gz |
macOS specific Info.plist file for Bluetooth Examples
The default generated Info.plist is not enough as the Bluetooth examples
require NSBluetoothAlwaysUsageDescription key to work. Without this
patch on macOS 12 there are two possible outcomes:
1) If the example is built with qmake, the application will crash
and the crash report will indicate that the key is missing
2) If the example is built with CMake, the application will not start
as it tries to use iOS specific .plist file
The patch uses absolute paths in the example CMakeLists.txt files
to work around a Ninja bug:
https://gitlab.kitware.com/cmake/cmake/-/issues/20181
Using relative paths resulted in "multiple rules generate" errors
if the QtConnectivity module is built with examples.
Note that the plist files are only effective if the application is
started as an app bundle, ie. not if launching the contained binary
directly.
Task-number: QTBUG-98090
Change-Id: Iedb7eabbb8fde6ad1ba14ada1a7ee87ec1d708ba
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 70d590a81cae3c122c68bcb4521f21771cf02d40)
-rw-r--r-- | examples/bluetooth/btscanner/CMakeLists.txt | 15 | ||||
-rw-r--r-- | examples/bluetooth/btscanner/btscanner.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/heartrate-game/CMakeLists.txt | 13 | ||||
-rw-r--r-- | examples/bluetooth/heartrate-game/heartrate-game.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/heartrate-server/CMakeLists.txt | 14 | ||||
-rw-r--r-- | examples/bluetooth/heartrate-server/heartrate-server.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/CMakeLists.txt | 13 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/lowenergyscanner.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/shared/Info.cmake.macos.plist | 24 | ||||
-rw-r--r-- | examples/bluetooth/shared/Info.qmake.macos.plist | 24 |
10 files changed, 107 insertions, 0 deletions
diff --git a/examples/bluetooth/btscanner/CMakeLists.txt b/examples/bluetooth/btscanner/CMakeLists.txt index d12609a6..7b8caa25 100644 --- a/examples/bluetooth/btscanner/CMakeLists.txt +++ b/examples/bluetooth/btscanner/CMakeLists.txt @@ -26,6 +26,21 @@ set_target_properties(btscanner PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) + +if (APPLE) + if (IOS) + set_target_properties(btscanner PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" + ) + else() + # Using absolute path for shared plist files is a Ninja bug workaround + get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE) + set_target_properties(btscanner PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist" + ) + endif() +endif() + target_link_libraries(btscanner PUBLIC Qt::Bluetooth Qt::Core diff --git a/examples/bluetooth/btscanner/btscanner.pro b/examples/bluetooth/btscanner/btscanner.pro index d5fd66ae..ee781ff7 100644 --- a/examples/bluetooth/btscanner/btscanner.pro +++ b/examples/bluetooth/btscanner/btscanner.pro @@ -10,6 +10,7 @@ SOURCES = \ service.cpp ios: QMAKE_INFO_PLIST = Info.plist +macos: QMAKE_INFO_PLIST = ../shared/Info.qmake.macos.plist HEADERS = \ device.h \ diff --git a/examples/bluetooth/heartrate-game/CMakeLists.txt b/examples/bluetooth/heartrate-game/CMakeLists.txt index 7567a97e..46401964 100644 --- a/examples/bluetooth/heartrate-game/CMakeLists.txt +++ b/examples/bluetooth/heartrate-game/CMakeLists.txt @@ -40,6 +40,19 @@ target_link_libraries(heartrate-game PUBLIC Qt::Quick ) +if (APPLE) + if (IOS) + set_target_properties(heartrate-game PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" + ) + else() + # Using absolute path for shared plist files is a Ninja bug workaround + get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE) + set_target_properties(heartrate-game PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist" + ) + endif() +endif() # Resources: set(qml_resource_files diff --git a/examples/bluetooth/heartrate-game/heartrate-game.pro b/examples/bluetooth/heartrate-game/heartrate-game.pro index a0827d89..02d238ad 100644 --- a/examples/bluetooth/heartrate-game/heartrate-game.pro +++ b/examples/bluetooth/heartrate-game/heartrate-game.pro @@ -20,6 +20,7 @@ SOURCES += main.cpp \ bluetoothbaseclass.cpp ios: QMAKE_INFO_PLIST = Info.plist +macos: QMAKE_INFO_PLIST = ../shared/Info.qmake.macos.plist RESOURCES += qml.qrc \ images.qrc diff --git a/examples/bluetooth/heartrate-server/CMakeLists.txt b/examples/bluetooth/heartrate-server/CMakeLists.txt index 9ec86f85..44032e10 100644 --- a/examples/bluetooth/heartrate-server/CMakeLists.txt +++ b/examples/bluetooth/heartrate-server/CMakeLists.txt @@ -37,6 +37,20 @@ if(ANDROID) ) endif() +if (APPLE) + if (IOS) + set_target_properties(heartrate-server PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" + ) + else() + # Using absolute path for shared plist files is a Ninja bug workaround + get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE) + set_target_properties(heartrate-server PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist" + ) + endif() +endif() + install(TARGETS heartrate-server RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/bluetooth/heartrate-server/heartrate-server.pro b/examples/bluetooth/heartrate-server/heartrate-server.pro index 992f2d66..8ec3f703 100644 --- a/examples/bluetooth/heartrate-server/heartrate-server.pro +++ b/examples/bluetooth/heartrate-server/heartrate-server.pro @@ -8,6 +8,7 @@ CONFIG += c++11 SOURCES += main.cpp ios: QMAKE_INFO_PLIST = Info.plist +macos: QMAKE_INFO_PLIST = ../shared/Info.qmake.macos.plist target.path = $$[QT_INSTALL_EXAMPLES]/bluetooth/heartrate-server INSTALLS += target diff --git a/examples/bluetooth/lowenergyscanner/CMakeLists.txt b/examples/bluetooth/lowenergyscanner/CMakeLists.txt index 45a5461d..f1341e1a 100644 --- a/examples/bluetooth/lowenergyscanner/CMakeLists.txt +++ b/examples/bluetooth/lowenergyscanner/CMakeLists.txt @@ -40,6 +40,19 @@ target_link_libraries(lowenergyscanner PUBLIC Qt::Quick ) +if (APPLE) + if (IOS) + set_target_properties(lowenergyscanner PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" + ) + else() + # Using absolute path for shared plist files is a Ninja bug workaround + get_filename_component(SHARED_PLIST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../shared ABSOLUTE) + set_target_properties(lowenergyscanner PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${SHARED_PLIST_DIR}/Info.cmake.macos.plist" + ) + endif() +endif() # Resources: set(resources_resource_files diff --git a/examples/bluetooth/lowenergyscanner/lowenergyscanner.pro b/examples/bluetooth/lowenergyscanner/lowenergyscanner.pro index 934f6cfa..31b243ac 100644 --- a/examples/bluetooth/lowenergyscanner/lowenergyscanner.pro +++ b/examples/bluetooth/lowenergyscanner/lowenergyscanner.pro @@ -11,6 +11,7 @@ SOURCES += main.cpp \ characteristicinfo.cpp ios: QMAKE_INFO_PLIST = Info.plist +macos: QMAKE_INFO_PLIST = ../shared/Info.qmake.macos.plist OTHER_FILES += assets/*.qml diff --git a/examples/bluetooth/shared/Info.cmake.macos.plist b/examples/bluetooth/shared/Info.cmake.macos.plist new file mode 100644 index 00000000..77c8db19 --- /dev/null +++ b/examples/bluetooth/shared/Info.cmake.macos.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string>${MACOSX_BUNDLE_ICON_FILE}</string> + <key>CFBundleIdentifier</key> + <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>LSMinimumSystemVersion</key> + <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSBluetoothAlwaysUsageDescription</key> + <string>Qt BT Example wants to access your Bluetooth adapter</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> diff --git a/examples/bluetooth/shared/Info.qmake.macos.plist b/examples/bluetooth/shared/Info.qmake.macos.plist new file mode 100644 index 00000000..80b3630b --- /dev/null +++ b/examples/bluetooth/shared/Info.qmake.macos.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>${PRODUCT_BUNDLE_IDENTIFIER}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>LSMinimumSystemVersion</key> + <string>${MACOSX_DEPLOYMENT_TARGET}</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSBluetoothAlwaysUsageDescription</key> + <string>Qt BT Example wants to access your Bluetooth adapter</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> |