Command Line Utility vs. Core Bluetooth Permissions

I'm writing a command line tool for macOS which interfaces with BLE devices. I have a problems with regards to permissions:

If I launch my tool on the command line, it gets killed by the OS. Only if I launch it via the debugger, I get the alerter to allow the bluetooth permission.

My plist that contains the NSBluetoothAlwaysUsageDescription key is embedded as __TEXT __info_plist in the binary. Is this no longer enough for a command-line tool to access security-guarded OS facilities these days?

Accepted Reply

FWIW, the culprit is the missing inherited permissions. When running the tool from iTerm (which is what I'm using as terminal emulator), it inherits the permissions from it. Granting Bluetooth permissions to iTerm fixes my problem.

Now: Is it possible that my command line program can detect this lack of (inherited) permission, thus preventing the crash and rather showing an instruction alert instead?

Replies

FWIW, the culprit is the missing inherited permissions. When running the tool from iTerm (which is what I'm using as terminal emulator), it inherits the permissions from it. Granting Bluetooth permissions to iTerm fixes my problem.

Now: Is it possible that my command line program can detect this lack of (inherited) permission, thus preventing the crash and rather showing an instruction alert instead?

@DrMickeyLauer have you figured this out? I am also making a console app that manages bluetooth devices and I have tried adding the NSBluetoothAlwaysUsageDescription key to a plist and embedding that into the binary via CREATE_INFOPLIST_SECTION_IN_BINARY and this does not work, what is the way to get this to work? it seems mostly an issue with xcode (xcode 14.2 at time of writing this) not picking up on this fringe case of not assigning an info.plist and not wanting an external file when it is made