What is `applet.rsrc` for?


(Doeke Zanstra) #1

I want to store my AppleScript-app in git, and I’m checking which files are really needed.

I’m skipping the *.rtfd files, since they are generated. But what is applet.rsrc for (the file is stored inside the app, with path Contents/Resources/applet.rsrc)?

(Mark Alldritt) #2

This file is required. It contains resources (stored in Resource Manager format) that the applet requires to operate. If is a binary data-fork file which should survive a trip through Git.

An alternative is to only store the source of your script (saved as text in a .applescript file), and then add to your build process to use the osacompile command to produce an applet.

(Doeke Zanstra) #3

I want to write an article on how to store applescript in git. Most questions have been answered. Yeah, you can do osacompile as a build script, and osadecompile/osacompile as a git filter. I’m looking at both.

My .gitignore looks like this. Do you have any additions?

# Script Debugger temporary files
Script Debugger.plist

# Generated files

(Mark Alldritt) #4

I recommend keeping all the files within a script bundle. All the files placed within a script or applet bundle serve an important purpose.

The Script Debugger.plist file is sacrificial in that it contains state information that you may not want to retain - window position, view settings, breakpoints, expressions, code signing settings, copyright notices, version numbers, etc. Loosing this information will not impact the script’s execution, but you should be certain you want this information discarded.

The description.rtf and description.rtfd files should be retained. This is your script’s description, and once these files are removed, that information cannot be recovered. If you are certain you never will have a description for your script(s), I supposed these can go, but a blanket exclusion of these files may hurt you at some point in the future.

The main.recover.rtf files are a judgement call. I recommend keeping them as they are source code backups of the AppleScript byte code stored in main.scpt. They are required in those instances where the byte code becomes corrupted (rare, but it happens). This file also serves as the backing store for Script Debugger’s QuickLook generator and allows QuickLook (and by extension Script Debugger’s Open Quickly feature) to function without having to launch all the apps the script references.

(Doeke Zanstra) #5

Thanks for the input. A lot makes sense.

A question about auto-save: does my wildcard work for all localised versions? It works fine for Dutch and English.

I omit Script Debugger.plist, because I think they are personal settings, and also machine specific. I work on two computers, with different monitor configurations for example. But in some cases, it would make sense. .gitignore will always need consideration about what to exclude.

And finally, in what way is the file description.rtfd actually being used by an .app, when you distribute it to your users?

(Mark Alldritt) #6

Not sure. But unless the auto-save documents are for scripts embedded within the applet, they should never be part of the applet’s bundle.

Okay, but be aware that not all of the settings retained in Script Debugger.plist are personal. Code signing, versioning, and a number of other settings do impact how the script is saved or executed.

Applets have a Show Startup setting, which when enabled causes a alert to appear when the applet is launched. This alert displays the script’s description. Even if you have this turned off, the user can summon it by launching the applet with the Option key held down.

As I say in my previous reply, I highly recommend keeping description.rtf and/or description.rtfd.

(Doeke Zanstra) #7

I didn’t know about the description.rtf functionality. I directly added it to my script. Holding option down when starting the app doesn’t show the description however.

Another question: I recreate the *.scpt document from a text .applescript document with osacompile. I can open the .scpt file with Script Debugger, but I can’t save it.

Error message:

Cannot Save Document
End of file (eofErr:-39).

When I first open and save the document with ScriptEditor, saving from Script Debugger works fine. So this is not about a bundle, but a single file.

The only difference I see, when I save the .scpt from ScriptEditor, some extended attributes are added, one of them com.apple.ResourceFork. When this attribute is removed again, Script Debugger can’t save it.

I create a test.scpt file like this:

echo 'display notification "Hello World"' | osacompile -o test.scpt

(Mark Alldritt) #8

I’m seeing this same error from other customers. It appears to be caused by changes in macOS High Sierra. I am looking into the issue and hopefully there will be a fix I can introduce into the next Script Debugger 6 maintenance release.


With SD I’m seeing a “Cannot save” error on 10.13 with any .applescript file previously saved with Script Editor. In addition when trying a “Save As…” in SD I’m getting this error:

The document “Untitled 3.applescript” could not be saved as “Untitled 3-sd.applescript”. The file doesn’t exist.

And Yes, stripping the extended attributes (including the resource fork) makes SD unable to save the document, even it was created by SD itself (Script Editor not involved). Script Editor handles it fine.

Similarly, when I create a fresh .applescript in BBEdit, SD can open it but not save it.

My current workaround is: Saving the text file as .scpt in Script Editor → Opening it with SD → Saving it as text.

(Mark Alldritt) #12

We have a fix for this in hand and will include it in the upcoming Script Debugger 6.0.6 maintenance release.