Skip to content

Commit

Permalink
Merge pull request #1820 from gtm19/fix-macos-photo-permissions
Browse files Browse the repository at this point in the history
Fix macOS camera / microphone / photo library permissions
  • Loading branch information
freakboy3742 committed May 21, 2024
2 parents ec0235f + 52fa7cb commit 7ffbb0a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/1820.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
macOS apps now generate ``info.plist`` entries for camera, photo library and microphone permissions.
10 changes: 7 additions & 3 deletions docs/reference/platforms/macOS/xcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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
===============
Expand Down
3 changes: 3 additions & 0 deletions src/briefcase/platforms/macOS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ 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
info["NSMicrophoneUsageDescription"] = cross_platform["microphone"]

if cross_platform["background_location"]:
info["NSLocationUsageDescription"] = cross_platform["background_location"]
Expand All @@ -182,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
Expand Down
12 changes: 9 additions & 3 deletions tests/platforms/macOS/app/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -89,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,
Expand Down Expand Up @@ -236,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,
Expand Down

0 comments on commit 7ffbb0a

Please sign in to comment.