diff options
author | Doris Verria <doris.verria@qt.io> | 2021-12-15 23:40:17 +0100 |
---|---|---|
committer | Doris Verria <doris.verria@qt.io> | 2021-12-17 12:45:41 +0100 |
commit | 767315b2049f0685f12de3418c658313851e8c0f (patch) | |
tree | 2e754aac8e89da7dab5aeb10d8c9b1bcef5bde6e /examples/multimedia/video/qmlvideo | |
parent | 77096edebd7dda161db42b92a5b3bc41f9c69740 (diff) |
Multimedia examples: Add camera and audio input entitlements
Apple needs apps to specify proper entitlements in order to grant the
executable permissions to use services like camera and microphone.
The multimedia examples using microphone and camera were sometimes
crashing because of missing entitlements. To fix, add an entitlement
file to all examples using these services, and add a post-build
command to codesign the executables with the specified entitlements.
Task-number: QTBUG-98419
Pick-to: 6.3 6.2
Change-Id: I6a578def1f6a41b4d106ee49c0c32fad304ef3cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/multimedia/video/qmlvideo')
-rw-r--r-- | examples/multimedia/video/qmlvideo/CMakeLists.txt | 11 | ||||
-rw-r--r-- | examples/multimedia/video/qmlvideo/qmlvideo.entitlements | 8 | ||||
-rw-r--r-- | examples/multimedia/video/qmlvideo/qmlvideo.pro | 10 |
3 files changed, 29 insertions, 0 deletions
diff --git a/examples/multimedia/video/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/CMakeLists.txt index c3eff7876..516f9b5c3 100644 --- a/examples/multimedia/video/qmlvideo/CMakeLists.txt +++ b/examples/multimedia/video/qmlvideo/CMakeLists.txt @@ -33,6 +33,8 @@ set_target_properties(qmlvideo PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS + "${CMAKE_CURRENT_LIST_DIR}/qmlvideo.entitlements" ) target_compile_definitions(qmlvideo PUBLIC @@ -123,3 +125,12 @@ install(TARGETS qmlvideo BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" ) + +if(APPLE AND NOT IOS) + if(NOT CMAKE_GENERATOR STREQUAL "Xcode") + add_custom_command(TARGET qmlvideo + POST_BUILD + COMMAND codesign --sign - --entitlements ${CMAKE_CURRENT_SOURCE_DIR}/qmlvideo.entitlements ${CMAKE_CURRENT_BINARY_DIR}/qmlvideo.app + ) + endif() +endif() diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.entitlements b/examples/multimedia/video/qmlvideo/qmlvideo.entitlements new file mode 100644 index 000000000..6cfee69ba --- /dev/null +++ b/examples/multimedia/video/qmlvideo/qmlvideo.entitlements @@ -0,0 +1,8 @@ +<?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>com.apple.security.device.camera</key> + <true/> +</dict> +</plist> diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro index 4fa9d2b3b..7d5717c3c 100644 --- a/examples/multimedia/video/qmlvideo/qmlvideo.pro +++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro @@ -85,3 +85,13 @@ INSTALLS += target EXAMPLE_FILES += \ qmlvideo.png \ qmlvideo.svg + +macos { + macx-xcode { + code_sign_entitlements.name = CODE_SIGN_ENTITLEMENTS + code_sign_entitlements.value = $$PWD/$${TARGET}.entitlements + QMAKE_MAC_XCODE_SETTINGS += code_sign_entitlements + } else { + QMAKE_POST_LINK += "codesign --sign - --entitlements $$PWD/$${TARGET}.entitlements $${OUT_PWD}/$${TARGET}.app" + } +} |