From 40f64e174a84e139537cbb3e346286512a0b311a Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 08:52:00 -0400 Subject: [PATCH 1/7] add test to show info.plist camera permissions not being added --- tests/platforms/macOS/app/test_create.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/platforms/macOS/app/test_create.py b/tests/platforms/macOS/app/test_create.py index 8fed84707..9bc5cab24 100644 --- a/tests/platforms/macOS/app/test_create.py +++ b/tests/platforms/macOS/app/test_create.py @@ -73,7 +73,9 @@ def create_command(tmp_path, first_app_templated): {}, {}, { - "info": {}, + "info": { + "NSCameraUsageDescription": "I need to see you", + }, "entitlements": { "com.apple.security.cs.allow-unsigned-executable-memory": True, "com.apple.security.cs.disable-library-validation": True, From 2e3eb59b6c95ff8e03a4a9d783edc67aec4ba051 Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 08:59:10 -0400 Subject: [PATCH 2/7] add fix: macOSCreateMixin.permissions_context now adds to plist info dict --- src/briefcase/platforms/macOS/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/briefcase/platforms/macOS/__init__.py b/src/briefcase/platforms/macOS/__init__.py index 415ebd3e8..f0ce85d34 100644 --- a/src/briefcase/platforms/macOS/__init__.py +++ b/src/briefcase/platforms/macOS/__init__.py @@ -168,6 +168,7 @@ def permissions_context(self, app: AppConfig, cross_platform: dict[str, str]): if cross_platform["camera"]: entitlements["com.apple.security.device.camera"] = True + info["NSCameraUsageDescription"] = cross_platform["camera"] if cross_platform["microphone"]: entitlements["com.apple.security.device.microphone"] = True From 36b9e28b1e49380afb19dbc45fc7f013a3ff66c0 Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 09:13:18 -0400 Subject: [PATCH 3/7] add similar tests for microphone and photo library support --- tests/platforms/macOS/app/test_create.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/platforms/macOS/app/test_create.py b/tests/platforms/macOS/app/test_create.py index 9bc5cab24..91ab045e1 100644 --- a/tests/platforms/macOS/app/test_create.py +++ b/tests/platforms/macOS/app/test_create.py @@ -91,7 +91,9 @@ def create_command(tmp_path, first_app_templated): {}, {}, { - "info": {}, + "info": { + "NSMicrophoneUsageDescription": "I need to hear you", + }, "entitlements": { "com.apple.security.cs.allow-unsigned-executable-memory": True, "com.apple.security.cs.disable-library-validation": True, @@ -238,7 +240,9 @@ def create_command(tmp_path, first_app_templated): {}, {}, { - "info": {}, + "info": { + "NSPhotoLibraryUsageDescription": "I need to see your library", + }, "entitlements": { "com.apple.security.cs.allow-unsigned-executable-memory": True, "com.apple.security.cs.disable-library-validation": True, From 8f0d651cefa32b51ee2735b7988d98571cfd3418 Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 09:18:50 -0400 Subject: [PATCH 4/7] fix photo and user library permissions --- src/briefcase/platforms/macOS/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/briefcase/platforms/macOS/__init__.py b/src/briefcase/platforms/macOS/__init__.py index f0ce85d34..e1ad5a874 100644 --- a/src/briefcase/platforms/macOS/__init__.py +++ b/src/briefcase/platforms/macOS/__init__.py @@ -171,6 +171,7 @@ def permissions_context(self, app: AppConfig, cross_platform: dict[str, str]): info["NSCameraUsageDescription"] = cross_platform["camera"] if cross_platform["microphone"]: entitlements["com.apple.security.device.microphone"] = True + info["NSMicrophoneUsageDescription"] = cross_platform["microphone"] if cross_platform["background_location"]: info["NSLocationUsageDescription"] = cross_platform["background_location"] @@ -183,6 +184,7 @@ def permissions_context(self, app: AppConfig, cross_platform: dict[str, str]): entitlements["com.apple.security.personal-information.location"] = True if cross_platform["photo_library"]: + info["NSPhotoLibraryUsageDescription"] = cross_platform["photo_library"] entitlements["com.apple.security.personal-information.photo_library"] = True # Override any info and entitlement definitions with the platform specific definitions From 8a6b7738fb5b35ec3ab922d6659def8239235fa8 Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 09:21:40 -0400 Subject: [PATCH 5/7] update .rst docs --- docs/reference/platforms/macOS/xcode.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/reference/platforms/macOS/xcode.rst b/docs/reference/platforms/macOS/xcode.rst index d00b8be04..6836acc1f 100644 --- a/docs/reference/platforms/macOS/xcode.rst +++ b/docs/reference/platforms/macOS/xcode.rst @@ -117,8 +117,10 @@ Permissions Briefcase cross platform permissions map to a combination of ``info`` and ``entitlement`` keys: -* ``microphone``: an ``entitlement`` of ``com.apple.security.device.audio-input`` -* ``camera``: an ``entitlement`` of ``com.apple.security.device.camera`` +* ``microphone``: an ``info`` entry for ``NSMicrophoneUsageDescription``; and + an ``entitlement`` of ``com.apple.security.device.audio-input`` +* ``camera``: an ``info`` entry for ``NSCameraUsageDescription``; and + an ``entitlement`` of ``com.apple.security.device.camera`` * ``coarse_location``: an ``info`` entry for ``NSLocationUsageDescription`` (ignored if ``background_location`` or ``fine_location`` is defined); plus an entitlement of ``com.apple.security.personal-information.location`` @@ -127,7 +129,9 @@ keys: ``com.apple.security.personal-information.location`` * ``background_location``: an ``info`` entry for ``NSLocationUsageDescription``; plus an ``entitlement`` of ``com.apple.security.personal-information.location`` -* ``photo_library``: an ``entitlement`` of ``com.apple.security.personal-information.photos-library`` +* ``photo_library``: an ``info`` entry for ``NSPhotoLibraryUsageDescription``; + plus an ``entitlement`` of + ``com.apple.security.personal-information.photos-library`` Platform quirks =============== From a12c4bfe4fb350eca0f377fd3231578da9b51ca5 Mon Sep 17 00:00:00 2001 From: Gareth Maddock Date: Tue, 21 May 2024 10:15:39 -0400 Subject: [PATCH 6/7] added change note --- changes/1820.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/1820.bugfix.rst diff --git a/changes/1820.bugfix.rst b/changes/1820.bugfix.rst new file mode 100644 index 000000000..59c3cf4de --- /dev/null +++ b/changes/1820.bugfix.rst @@ -0,0 +1 @@ +App will no longer crash on macOS when camera, photo library, or microphone access is requested. From 52fa7cb8f903a4fc343bdd4ddd6131b0fe45e2ba Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 21 May 2024 11:51:08 -0400 Subject: [PATCH 7/7] Tweak release note. --- changes/1820.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/1820.bugfix.rst b/changes/1820.bugfix.rst index 59c3cf4de..a2f4a2e74 100644 --- a/changes/1820.bugfix.rst +++ b/changes/1820.bugfix.rst @@ -1 +1 @@ -App will no longer crash on macOS when camera, photo library, or microphone access is requested. +macOS apps now generate ``info.plist`` entries for camera, photo library and microphone permissions.