AESendMessage() only returns Apple Event Manager errors. For application errors you have to inspect the reply event.
I strongly recommend you write your tests in AppleScript. The language *****, but it’s the de facto reference against which all scriptable apps are measured. There are a lot of subtle (and not-so-subtle) wrinkles in its Apple event behavior which your own code is not guaranteed to replicate.
If you really insist on using Swift, you might consider using SwiftAutomation. Caveat emptor, etc, but it has pretty good quirk-for-quirk compatibility with AppleScript and is a lot less work than rolling Apple events from scratch. Last stable release:
github [dot] com/hhas/SwiftAutomation/commit/d5748e5e2ceea9abb37a090aabf2ba2fe4649443
Thanks for the answer!
I will check the SwiftAutomation, that seems pretty useful for what we need.
On the other hand, do you know how is the error stored in the reply event? If we do not modify it in the handler function, I would assume that it is returned as was received... so, would we need to store the result information in the handler or is the return code automatically stored?
Among the parameters received by our application, there are arrays of data which afterwards processed differently according to the type stored in the parameter. I believe there is no easy way to read this using AppleScripts. And we cannot intervene with how the client app is sending the information since it does not belong to us. Am I right in assuming this?
do you know how is the error stored in the reply event?
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"