How to locate the latest version of Script Debugger in code?

So I have an app ( that can run applescripts. I want to add an option to open the scripts in an editor. By default, I want to check if the user has SD installed, and then open that, otherwise fall back to Apple’s Script Editor.

So I thought I’d use LaunchServices and ask for the SD app by its bundle ID. But it turns out that SD’s bundle ID appears to keep changing, i.e. it has a version number in the bundle ID! So that’s not great for my purpose.

Another way would be to find apps that can handle a particular file extension, with the role “editor”. Looking at SD 7’s supported extensions, “.scptd” appears to be one of them.

Now I wonder: how far back is that type supported, and is it planned to remain?

Or is there a smarter way to do this?

(later) Huh, I had thought that “scptd” would be a SD specific extension, but it turns out that Apple’s SE knows it, too. So I guess I could just look for the default editor for the to-be-edited file (with LSCopyDefaultApplicationURLForURL or [NSWorkspace URLForApplicationToOpenURL:]) and use that to open the script file. That way, the user can assign his preferred editor for the scpt file in Finder and I don’t have to worry further about giving more options.

That, or simply use openURL:.

Huh, OpenURL - of course. .scpt files are sources, after all!
I had it somehow in mind that they’d be run if double clicked. Jeez, that’s what happens if you’re programming after two beers in the Biergarten.

1 Like

Your code looks for Script Debugger by file name. I’m skeptical if that still works if the user renames the app, e.g. to “Script Debugger 8”, as I often do, keeping multiple app versions around (mainly for Xcode).

Just tested it - it doesn’t find a renamed app.

That’s why I wrote that I’d intend to find it by its bundle ID, because that can’t get renamed by the user.