Yes, this is a problem that I recognize. Unfortunately, a solution was outside the scope of the Script Debugger 6.0 effort.
What follows is simply an explanation, not a defence of the current state of affairs.
AppleScript provides a very limited API for developers, and absolutely nothing to facilitate debugging. Everything Script Debugger offers is done by various forms of hacks. Think of Script Debugger as a Porsche 911: a really bad idea executed very well.
Back before the appearance of AppleScript Libraries, AppleScript scripts were monolithic. Sure, you could use the load script
command and Script Debugger had its own library facilities, but most scripts were the result of a single compilation unit.
Script Debugger’s exploits this single compilation unit model to introduce its debugging hooks at compile time. This is accomplished using Script Debugger’s own OSA component (~/Library/Components/Script Debugger.component
). The use of a custom OSA component facilitates debugging within other host applications (Mail, etc.).
But, as always, there is a problem when AppleScript loads code on the user’s behalf (load script
, use script
, run script
). These actions take place within AppleScript and beyond the reach of Script Debugger. As a result, Script Debugger is unable to introduce its debugging hacks where needed. Further, because Script Debugger uses its own OSA component, AppleScript interprets code saved with debugging enabled as something other than AppleScript and reports the errors you are seeing.
There are other issues as well: Script Debugger’s UI is built around the we need to adopt an Xcode-like UI where a script is composed of many source documents. This is a massive change.
To do libraries correctly I first need to find a new means of introducing Script Debugger’s debugging hacks into loaded code. I have ideas for this, based on the notion of JIT de-compilation and re-compilation. But even with that approach, there will be situations (i.e. use script
in the body of a script) where Script Debugger will not be able to do its magic. Then, the entire Script Debugger UI for document management will have to be implemented, ore or less, from scratch to support a multi-source documents/script modal. There are side issues such as ensuring AppleScript re-loads libraries when are edited and the main script is not compiled, etc.
Quite frankly, Script Debugger’s market is so vanishingly small that its not clear that I can justify the investment needed to make all this happen. It remains to be seen if the reduction in price stimulates sales enough to justify this kind of effort. So far, we are in a negative position, compared to the release of Script Debugger 5.