得到;应用程序isn’;我不跑步。(错误-600)“;在swift中执行applescript时

得到;应用程序isn’;我不跑步。(错误-600)“;在swift中执行applescript时,swift,xcode,macos,applescript,Swift,Xcode,Macos,Applescript,我正试图在我的macOS应用程序中运行带有模块AppleScriptObjC的apple脚本,apple脚本代码如下所示: OS: MacOS Catalina 10.15.1 Language: Swift IDE: Xcode 调用testDialog()后,会显示日志消息,但是对话框“Hello World”没有出现。我得到一个错误Finder得到一个错误:应用程序没有运行。(错误-600) 更新 当使用应用程序名而不是“Finder”时,“Hello World”将正确显示。但是,显

我正试图在我的macOS应用程序中运行带有模块
AppleScriptObjC
的apple脚本,apple脚本代码如下所示:

OS: MacOS Catalina 10.15.1
Language: Swift
IDE: Xcode
调用
testDialog()
后,会显示日志消息,但是
对话框“Hello World”
没有出现。我得到一个错误
Finder得到一个错误:应用程序没有运行。(错误-600)


更新
当使用应用程序名而不是“Finder”时,“Hello World”将正确显示。但是,
显示通知仍然不起作用。

您没有显示实际的函数调用(例如,
测试的test()
)或它的上下文。我建议重命名脚本对象(奇怪的是,脚本对象与它的一个处理程序同名),并且调用“系统事件”而不是“查找器”。System Events.app的脚本编写错误较少。@TedWrigley,谢谢您的回复。我已将函数名从
test
更改为
testDialog
。希望它更准确。
“系统事件”
也不起作用,错误消息也是一样的。使用应用程序的名称仍然有效(“Hello World”显示正确)。错误-600似乎是一个沙箱问题。您必须在info.plist中添加
nsappleeventsagedescription
键。非常感谢@vadian!它工作得很好。
-- test.applescript
script test
    property parent : class "NSObject"

    to testDialog()
        log "This is log msg."
        tell application "Finder"
            display dialog "Hello World"
        end tell

        display notification "This is notification Content" with title "This is notification Title"
    end testDialog
end script