One application of bundles that I make use of, now and then, is to store a description and/or help file.
The description can by read in the AppleScript Editor, after clicking the appropiate button in the bottom bar of the script’s window. It is stored in a resource named “description.rtfd”, which is created automatically with the bundle.
I use help files mainly with libraries; they open when the script is run from the Script Menu.
(Adam Bell once posted a script, possibly in an Unscripted article, which taught me how to do that.)
These are also resources, and can be anything: text, pdf, screenshot.
My problem: sometimes these resources get lost when I update them, and save their bundle somewhere else, or with another name. I’m sure I’m missing the obvious, but…how can a resource go missing?
I haven’t the faintest clue as to why your resources get lost, and it is a great tip really.
I have however a way to avoid it, until it ships, and that is to have your final work in a products folder, ( you work and upgrade it elsewhere), and then you alias it into the bundle. The alias thing from a products folder works great for me when it comes to all things scripting, where it shines, is when stuff are put into bundles, like scripts etc. Then I know for sure where the latest version really is, you have to pack it of course, before you ship.
Yes, keeping the ‘under construction’ stuff separated from the finished product helps staying sane.
But while tinkering with script bundles just now I think I figured out what happened.
The Editor will only copy an existing resource named “description.rtfd”: anything else seems to be ignored.
Change that file to rtf or txt, or its name, and a new version of the bundle will contain a new ‘description.rtfd’ file.
I’ll have to look and see if there is a plist entry. What I suspected was the culprit, was that a bundle was sort of an abstraction of a file, and the stuff you had stuffed into the resources folder, was wiped away, by being in the resource fork of a file, when either being zipped, or put on another volume.
My way of organizing stuff won’t work well when different volumes (except for Time Machine ) is involved.
It is great for stuff on my own machine that are both under construction, and stuff that are finished, stuff that are under construction doesn’t really belong into the products folder, but it is a great place to test from too.
I also write my script as script objects now adays, so I can use the same script in an applet, or an automator service, just having the same copy in the products folder.
The different versions of the scripts are residing in their own folder besides the products folder, and ideally has a test folder within it.
This is very practical for me at least, no more wondering if I edited the script in the scripts menu, or the one in the project folder for instance!