import ScriptingBridge
class iTunesAccess {
static func requestAccess() -> Bool {
guard #available(OSX 10.14, *) else {
return true
}
if var addressDesc = NSAppleEventDescriptor(bundleIdentifier: "com.apple.iTunes").aeDesc?.pointee {
let appleScriptPermission = AEDeterminePermissionToAutomateTarget(&addressDesc, typeWildCard, typeWildCard, true)
AEDisposeDesc(&addressDesc)
return appleScriptPermission == noErr
}
return false
}
}
info.plist:
<key>NSAppleEventsUsageDescription</key>
<string>somedescriprtion</string>
iTunes running but i always get -600 osstatus. How i can fix it? iTunes bundle id is fine.
/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/iTunes.app/Contents/Info.plist
com.apple.iTunes
P.S but if i using "com.apple.dt.Xcode" bundle id it works!
P.P.S i found repo https://github.com/melchor629/iTunes-Scrobbler and build it. It works too.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With