Debugging Xcode AppleScriptObjectiveC

(Kerm Steffenhagen) #1

I may have missed a write up on this if it exists …

I am working on a project where I want to control an app with AppleScript but have a user GUI much more elaborate than the dialog commands built into AppleScript. I tried the new Scripting Bridge in Xcode but it was too slow to do all but trivial control of a scriptable app. From internet research it appears like I am not the only one with that disappointment.

In that regard, can Script Debugger be used to debug an Applescript application created by the “new” Xcode AppleScriptObjC? I understand how to use Script Debugger with ApplescriptObjC to write and debug ObjC, and I know how to create an Xcode Applescript Application with an associated InterfaceBuilder GUI, but wonder if there is a way to use SD in that environment not only to edit the source, to debug the app ?

(Jim Underwood) #2

I also have long wanted a better GUI than AppleScript can provide.

One solution is to use the Custom HTML Prompt provided by Keyboard Maestro. This “prompt” is basically a custom web page that you can design to use any HTML and JavaScript that you like. It does NOT require a web server – it launches directly from your desktop. It allows you to use KM Variables to communicate data between AppleScript and the HTML Prompt. In fact, you can invoke the HTML Prompt directly from AppleScript.

Of course, this does require both you and your users to have Keyboard Maestro installed. IMO, KM is, hands down, the best Mac automation tool I have ever used, and it supports embedded AppleScript, JXA, Shell Scripts, and more. You can try it for free for 30 days (no limits). If you decide to buy, use this link for a 20% discount.

For more info about the KM HTML Prompt, see:

Good luck with whatever choice you make. If you come up with a good alternate GUI solution, please share it.

(Shane Stanley) #3

Alas, no.

Depending on your GUI, you might be able to factor it out into a framework and load it that way. My Myriad Tables Lib is the sort of thing I mean. But that requires a largely modal structure.

(Kerm Steffenhagen) #4

Thank you for the KM suggestion, I’ll look into it.

Does KM support controls that send events to your script, like buttons?

(Kerm Steffenhagen) #5

I will probably go the route of using ASObjC and debug with log messages. I can use Script Debugger to “unit test” some of the routines before plugging them into the application.

(Jim Underwood) #6

Not directly, but your script can call the HTML Prompt, and wait for a response. Then, the button name is returned as a KM Variable, which your script can read.

(Jim Underwood) #7

@ksteff, KM is still one option, but I have just learned how much easier it is to use Xcode than I originally thought.


(Jim Underwood) #8

I have recently discovered that the answer is yes, if you put the core AppleScript in a separate script file (script library).