苹果系统。如何请求访问每个应用程序上的系统事件?

rmv*_*vz3 4 cocoa applescript entitlements swift

我需要我的 Mac Swift 应用程序使用系统事件(通过 Applescript)来关闭用户添加到列表中的任何应用程序。我在系统偏好设置中看到许多应用程序可以在自动化面板中访问系统事件(例如“Google 的备份和同步”或“Divvy”)。我怎样才能请求许可呢?

vad*_*ian 6

NSAppleEventsUsageDescription在 Info.plist 中添加源代码视图中的键

<key>NSAppleEventsUsageDescription</key>
<string>$(PRODUCT_NAME) needs to control System Events</string>
Run Code Online (Sandbox Code Playgroud)

Privacy - AppleEvents Sending Usage Description在属性列表视图的弹出菜单中。

<string>值是任意描述。

此外,在启用了 Hardened Runtime 的 Xcode 11 中,您必须选中该Apple Events复选框