Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.apple.iTunes AEDeterminePermissionToAutomateTarget is always return -600

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.

like image 325
Horoko Avatar asked Oct 10 '18 22:10

Horoko


1 Answers

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.

like image 102
Chris N Avatar answered Nov 12 '22 06:11

Chris N