我如何自定义在我的应用程序中运行AppleScript时出现的消息

问题描述 投票:0回答:1

我正在创建需要在其他应用程序上执行AppleScript的应用程序>>

请考虑以下代码段。

let myAppleScript = "tell application \"Finder\" to close window 1 where name is \"Documents\""

var error: NSDictionary?
if let scriptObject = NSAppleScript(source: myAppleScript) {
    let output = scriptObject.executeAndReturnError(&error)
    print("AppleScript output: ", output.stringValue ?? "")
}

第一次执行此命令时,macOS会显示以下消息,提示/对话框

“Xcode“ wants access to control “Finder“. Allowing control will provide access to documents and data in “Finder“, and to perform actions within that app.

((当我直接运行我的应用程序时,Xcode当然会替换为我的应用程序的名称-当前,我正在Xcode中测试该应用程序。)

我想在此消息中添加另一行,以告知用户我的应用为何需要此许可。

我怎样才能做到这一点? (我看过另一个应用程序可以做到这一点,所以我知道这是可能的。)

我正在创建一个需要在其他应用程序上执行AppleScript的应用程序。请考虑以下代码段。让myAppleScript =“ tell application \” Finder \“关闭窗口1,其名称为\” Documents \“” ...

swift applescript
1个回答
0
投票

您必须在Info.plist中添加一个键值对

  • 在源代码视图中添加

© www.soinside.com 2019 - 2024. All rights reserved.