import ScriptingBridge
class iTunesAccess {
static func requestAccess() -> Bool {
guard #available(OSX 10.14, *) else {
return true
}
Good call on the NSAppleEventsUsageDescription
key — that’s required if you link against the 10.14 SDK — but if your app is sandboxed, you’ll also need an appropriate Apple event entitlement: com.apple.security.scripting-targets
if you can, or com.apple.security.temporary-exception.apple-events
if you must. See https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AppSandboxTemporaryExceptionEntitlements.html for more details, including a way to specify both entitlements, but only one applies depending on the current OS version.