Sandbox entitlement to script iTunes via NSAppleScript
问题 I'm trying to script iTunes from NSAppleScript in my Cocoa app in order to add a file to the library. In my entitlements file, I added the following: <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.itunes</key> <array> <string>com.apple.itunes.library.read-write</string> </array> </dict> I then call the AppleScript like this: var error: NSDictionary? = nil let appleScript = NSAppleScript(source: "tell application \"iTunes\" to add (POSIX file \"\(path)\") to library