OS: MacOS Catalina 10.15.1
Language: Swift
IDE: Xcode
I'm trying to run an apple script with module AppleScriptObjC
in my macOS app, and the apple script code is showed below:
-- 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
After calling testDialog()
, the log message showed, but dialog "Hello World"
did not appear. And I got an error Finder got an error: Application isn’t running. (error -600)
.
Updated
When using the app name instead of "Finder", "Hello World" will display correctly. However, display notification
still won't work.