SD8: Direct Export

Script Debugger 8 simplifies exporting of run-only scripts by making it a one-step process, which we call Direct Export. It’s part of a suite of changes to help users better manage scripting projects. As the requirements for scripts become more complicated with issues like code-signing and notarizing, these changes make it more convenient to separate the development and deployment processes.

At its heart, the new process works by storing your export settings, so they do not have to be re-entered each time you export. So when you decide your script is ready to be deployed, you go to the Export Run Only submenu of the File menu and choose the required file format. Unless you choose the Custom… option, there is no more save panel with checkboxes and popup menus to deal with.

The key to this process lies in two places: the Bundle & Export Settings dialog, and the new Building pane in Preferences.

Bundle & Export Settings combines some of the settings from the Script Debugger 7 Resources tab, plus some new ones – for example, you can set the name to be used for the exported file, allowing you to use more descriptive names for your editable files, and not have to modify names every time you export. You can read more about this new dialog here <>.

The Building panel in Preferences is the place you control where files are exported to. Defining a consistent destination again removes the need to navigate through folders each time you export. But Direct Export goes a step further: when you export, the file is saved within a specially named folder, which is created if necessary. This makes it near impossible to accidentally overwrite you editable version, while creating a record of what was exported when.

The Building pane gives you control over where the file and its enclosing folder are saved, and how the folder is named. By default, the new folder will be created in the same folder as the file you are exporting. Alternatively, you can choose to have all exported folders saved to a single repository folder. Choose which best suits your workflow.

The name of the folder is specified using a template, which uses placeholders similar to those used in clippings or in the Copyright Template in General Preferences. The placeholders you can use in this template are:

[[filename]] This is replaced by the name of the file you are exporting from, minus any extension.
[[date]] This is replaced by a full date and time string, like this: “2020-11-29 14.45.32”
[[short-date]] This is replaced by a date-only string, like this: “2020-11-29”
[[GMT-date]] This is replaced by a full UTC/GMT date and time string, like this: “2020-11-29 14.45.32Z”
[[version]] This is replaced by the version as entered in the Build & Export settings, or “" if none set.
[[build]] This is replaced by the Build # as entered in the Build & Export settings, or "
” if none set.

When you enter a template and hit return, a preview of the name appears below the field.

By including these values in the folder name, you can easily keep track of what changes you made, and when.

The last checkbox in the Building panel is Include SD Script Notes file in export folder. Documenting changes to projects as you write them, or as requirements change, can be a haphazard business. Comments can only record so much, and they require access to the source. Script Debugger 8 introduces an optional new file, called `SD Script Notes.rtfd``, which lives in a bundle or applet’s Resources folder. You can create it yourself, or use the contextual menu in the Contents section of the Resources Tab.

The document serves as a place for you to document things so that they will not be accidentally separated from the code. You can use it as a Read Me file, or as something more technical, but it will not be included in any applet or bundle when you export a run-only version. However, when this option is checked, any such file in a project will also be copied — not in, but along-side the exported file.

Combined with the export folder naming template options above, this means you can end up with a record of which version you exported when, plus documentation of the changes made.

Our exports are all done by script.

I’m having issues with Bundle ID… in Script Debugger, I go to
File → Bundle and Export Settings

And fill in the Bundle ID and click “OK.”

Our script that exports our scripts uses this line for the save:
save activeDoc in POSIX file savePath as exportFormat with run only
but the resulting script, if saved as a run-only application, does not have the bundle ID that was set, it has a generic bundle ID, what it would have if nothing had been filled in.

Do I have to use the new “direct export” command to have it honor the Bundle ID I’ve filled in? It looks to me like the “direct export” command does not accept the save path as an argument - that the save location needs to be set in Script Debugger’s general preferences under
Building → Create All Export Folders in the Same Place. It wasn’t clear to me if this value could be set via Applescript.
Any help with this would be appreciated.

I tried this script:

set savePath to POSIX path of (((path to desktop) as text) & "Test export.app")
tell application id "com.latenightsw.ScriptDebugger8" -- Script Debugger.app
	set bundle ID of document 2 to "foo.was.here" -- assumes second script open
	save document 2 in POSIX file savePath as script application with run only
end tell

It works as expected. Can you try it there?

That’s correct. But it does return a reference to the exported file, which you can then move/copy.

This works. I realized that the actual issue was in our scripts and how hey handle saving apps, not in Script Debugger.

Thanks for you help,

tspoon.