Need to add "version" to a Service

I have a workflow which is installed as a Service. I created and edit the workflow in Automator. It is used to call code in my AppleScript applet. The Service has one action: a “Run AppleScript” action.

My applet installs the Service for users and I update the Service quite often. On startup, the applet checks whether the installed copy of the Service needs to be updated. Currently it does that by comparing file sizes – if the user’s copy is a different size to the current version, the applet updates it.

I need another method. That is because the applet now enables the user to change the NSMenuItem key in the Service’s info.plist which changes the size of the file and so the user’s copy is wrongly replaced by the current applet code.

One alternative is to assign a version to the Service. Then, if the user’s copy of the Service is an old version, it can be replaced by the new version. But, I can’t find an elegant or Apple approved method for versioning a Service. I have tried:

  • Adding a custom text file to the Service’s bundle which contains the version number. That works but is not elegant and relies on my remembering to update that text file with each new version of the Service.

  • Adding relevant keys to the Service’s info.plist file: CFBundleVersion; CFBundleShortVersionString. That could work but, those keys are removed from the info.plist file by Automator. Adding NSUserData to NSServices in the info.plist file. Again, could work but is also removed by Automator.

  • Add a comment to the AppleScript code inside the workflow which can be interrogated by my applet. That does work but, opening and reading the workflow file seems like over-kill and runs the risk of that file being over-written or the XML code being corrupted.

  • Using the “Set Value of Variable” action in the workflow – I can’t get that to work. Anyway, I suspect I would have to remember to add that action to update the version variable then delete it before bundling with the applet.

Most of the difficulty I’m having is with Automator which overwrites or removes custom keys in the info.plist file. Is there a way to stop Automator doing that, or is there an alternative editor which can replace Automator ?



BTW, is there a way to get lists showing properly using BBCode ? I tried numerous formulations (based on the help) but nothing worked.