加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – com.apple.iTunes AEDeterminePermissionToAutomateTar

发布时间:2020-12-14 05:01:12 所属栏目:百科 来源:网络整理
导读:import ScriptingBridgeclass iTunesAccess { static func requestAccess() - Bool { guard #available(OSX 10.14,*) else { return true } if var addressDesc = NSAppleEventDescriptor(bundleIdentifier: "com.apple.iTunes").aeDesc?.pointee { let appl
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,true)
            AEDisposeDesc(&addressDesc)
            return appleScriptPermission == noErr
        }
        return false
    }
}

info.plist中:

<key>NSAppleEventsUsageDescription</key>
<string>somedescriprtion</string>

iTunes运行但我总是得到-600 osstatus.
我怎么解决它?
iTunes捆绑包ID很好.

/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/iTunes.app/Contents/Info.plist
com.apple.iTunes

P.S但是,如果我使用“com.apple.dt.Xcode”捆绑包ID它的工作原理!

P.P.S我发现回购https://github.com/melchor629/iTunes-Scrobbler并建立它.它也有效.

解决方法

好好调用NSAppleEventsUsageDescription键 – 如果你链接到10.14 SDK就需要 – 但如果你的应用是沙箱,你还需要一个合适的Apple事件权利:com.apple.security.scripting-targets如果可以,或者com .apple.security.temporary-exception.apple-events如果必须的话.有关详细信息,请参阅 https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AppSandboxTemporaryExceptionEntitlements.html,其中包括指定两种权利的方法,但只有一种适用,具体取决于当前的操作系统版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读