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
}
}
Run Code Online (Sandbox Code Playgroud)
info.plist中:
<key>NSAppleEventsUsageDescription</key>
<string>somedescriprtion</string>
Run Code Online (Sandbox Code Playgroud)
iTunes运行但我总是得到-600 osstatus.我怎么解决它?iTunes捆绑包ID很好.
/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/iTunes.app/Contents/Info.plist
com.apple.iTunes
Run Code Online (Sandbox Code Playgroud)
PS,但如果我使用"com.apple.dt.Xcode"捆绑ID它的工作原理!
PPS我找到了repo https://github.com/melchor629/iTunes-Scrobbler并构建它.它也有效.