Forum Navigation
You need to log in to create posts and topics.

Re: FB's #plist command and Privacy Permissions

Posted by: richlove <richlove@...>

Good Information

Thanks,
Rich

> On Apr 13, 2022, at 5:16 PM, Ken Shmidheiser charset=us-ascii <kashmidheiser@gmail.com> wrote:
>
>
> The #plist command recently added to FB is exceptionally handy, and will prove even more so in the future as example demos grow more sophisticated.
>
> As an example, suppose we write a program that needs access to the Mac's microphone and camera. In the past we would have had to open the compiled app's Info.plist in Xcode or another editor, and manually add the keys and information strings that would generate dialog prompts that allowed the user to grant permission for the app to access the system's mic and camera.
>
> With FB's #plist command, we can now add the relevant keys and information strings directly in our code, and FB will automatically add them to the app's Info.plist. Example:
>
> #plist NSMicrophoneUsageDescription @"Your microphone will be used to record sounds."
> #plist NSCameraUsageDescription @"Your camera will be used to record video."
>
> When the user launches the app for the first time, prompt window will open asking the user to grant permission for the app to use the Mac's camera and mic. The prompt dialog will carry the message specified in #plist. If the user approves, permissions are then registered as persistent permission/s for that particular app in:
>
> System Preferences -> Security & Privacy -> Privacy tab
>
> in this case under the respective Camera and Microphone categories.
>
> The warning here is that app permissions are registered under the app's Bundle ID. When we test run FB code without a custom Info.plist, the resulting app is given the default Bundle ID:
>
> com.FutureBasic.demo
>
> Thereafter, every generic FB app with that Bundle ID will automatically have permissions to access the mic and camera. And in the Privacy tab you'll find the generic FB Blue Leaf app icon under whatever name you had assigned the code, or the name of the main window.
>
> A much better solution is to assign your code a unique Bundle ID from the outset. The #plist command makes that easy:
>
> #plist CFBundleIdentifier @"com.JohnSmith.MyGreatApp"
>
> The question arises: How can I remove an app once it's been registered with Security & Privacy. The answer is the tccutil terminal command.
>
> For instance, to remove generic FB apps registered under any service in the Privacy tab you would use:
>
> tccutil reset All com.FutureBasic.demo
>
> If you wanted to remove a generic FB app registered under a specific service, the command would be similar to:
>
> tccutil reset Microphone com.FutureBasic.demo
>
> Since I've begun regularly assigning my apps unique Bundle IDs, I add a comment to the code as a reminder:
>
> #plist CFBundleIdentifier @"com.futurebasic.CameraCapture"
> /*
> Terminal command to remove app from System Preferences -> Security & Privacy -> Privacy tab:
>
> tccutil reset All com.futurebasic.CameraCapture
> */
>
> More information is available in the tccutil man page.
>
> A while back when Location Services code was being shared on the list, some of these things were mentioned. However, that was before the handy #plist command was added to FB.
>
> Hope this may be of help going forward.
>
> Ken
>
>
>
>
>
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@freegroups.net
> To access the list archives, go to: freegroups.net/groups/futurebasic/
>
>
>