Sandbox entitlement to script Music/iTunes's AirPlay devices

I'm writing a Cocoa app that scripts various functions of the Music app. I'm successfully scripting a number of operations (create playlist, play tracks), but all AirPlay ops (get devices, set device volume) are failing with a permissions error: "-[Music airplayDevices_]: Music got an error: A privilege violation occurred. (error -10004)"


Details:

  • I'm using the AppleScriptObjC framework from Swift
  • targeting Catalina/Music, but have the same failures in Mojave/iTunes
  • code succeeds when not sandboxed - only fails in the sandbox


The entitlements file includes the following:

  <key>com.apple.security.scripting-targets</key>
  <dict>
  <key>com.apple.Music</key>
  <array>
  <string>com.apple.Music.device</string>
  <string>com.apple.Music.user-interface</string>
  <string>com.apple.Music.playback</string>
  <string>com.apple.Music.playerInfo</string>
  <string>com.apple.Music.library.read</string>
  <string>com.apple.Music.library.read-write</string>
  <string>com.apple.Music.podcast</string>
  </array>
  </dict>


i.e. all access-groups I could find using "sdef /System/Applications/Music.app". According to the sdef, AirPlay access is controlled by com.apple.Music.playback, which is included above.


I assume I need some other entitlement as well, but I can't for the life of me find out what it is.

You may also need to add the Hardened Runtime: Apple Events capability

Sandbox entitlement to script Music/iTunes's AirPlay devices
 
 
Q