Can't open usb device after signing my app with sandbox in entitlements.plist

This is my entitlements.plist:

    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.device.usb</key>
    <true/>

Check signing result, I run

codesign -d --entitlements :- ./dist/My.app
codesign -vv ./dist/My.app

and I get this

Executable=/dist/My.app/Contents/MacOS/main
Warning: Specifying ':' in the path is deprecated and will not work in a future release
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.app-sandbox</key><true/><key>com.apple.security.device.usb</key><true/><key>com.apple.security.network.client</key><true/><key>com.apple.security.network.server</key><true/><key>com.apple.security.temporary-exception.files.absolute-path.read-only</key><array><string>/private/etc/apache2/mime.types</string></array></dict></plist>

./dist/My.app: valid on disk
./dist/My.app: satisfies its Designated Requirement

But when I run my app, I got

['/dev/cu.Bluetooth-Incoming-Port', 'n/a', 'n/a']
['/dev/cu.usbmodem23401', 'GD32 USB CDC ACM in FS Mode', 'USB VID:PID=28E9:018A SER=GD32F30X-3.0.0-7z8x9yer LOCATION=2-3.4']
(1, "could not open port /dev/cu.usbmodem23401: [Errno 1] Operation not permitted: '/dev/cu.usbmodem23401'")

My app can't access to my usb device, how can I solve this? My app is worked without setting this

<key>com.apple.security.app-sandbox</key>
<true/>
Answered by DTS Engineer in 772056022

The droid you’re looking for here is com.apple.security.device.serial.

That entitlement is documented in our legacy docs but not in our modern docs. I’ve file a bug (r. 118341000) about that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

The droid you’re looking for here is com.apple.security.device.serial.

That entitlement is documented in our legacy docs but not in our modern docs. I’ve file a bug (r. 118341000) about that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Can't open usb device after signing my app with sandbox in entitlements.plist
 
 
Q