Use macOS . entitlements with SwiftPM or swift command line

Is there a way to pass .entitlements to spm or swift command line compiler?

I've been told you can technically pass -sectcreate __TEXT __info_plist /path_to_plist to the linker but I can't find a way to pass this via the swift command line.

2 Likes

Same problem here, trying to access USB from an SPM command line tool fails.

Did you solve linking an entitlements file in the meantime?

I don’t have any insight into the SwiftPM side of this but I want to clarify the problem space…


Jacopo Mangiavacchi wrote:

I've been told you can technically pass -sectcreate __TEXT __info_plist /path_to_plist to the linker

That sets the executable’s information property list (Info.plist), not its entitlements. Entitlements claims are part of the code signature. These are very different


Dr. Mickey Lauer wrote:

trying to access USB from an SPM command line tool fails.

On macOS entitlements are divided into two categories:

If you’re trying to use a restricted entitlement you can’t just claim the entitlement in your code signature. You have to also include a provisioning profile to authorise that claim. There’s no good way to do that for a command-line tool. Your only option is to place the tool in an app-like wrapper, as described in Signing a daemon with a restricted entitlement.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

2 Likes