I have written some AppleScripts that supplement weather station management software. I was aware of differences in the AppleScript application format between OS-10.5, OS-10.6, and OS-10.7 and the AppleScript application format is clearly not upward compatible.
My question is whether or not you can rely on downward compatibility? If someone is running on Lion, will their AppleScripts reliably run on Snow Leopard and Leopard. The weather software I work with runs on all three and the user-community spans that range of OS-X. What is the experience of this forum? Can I count on downward compatibility or not?
Yes it is downwards downwards compatible. But almost every system update some things will chance. New features can’t be used on older systems like the text item delimiters with list of delimiters for example. So you need to write ‘old’ code to make it compatible with Leopard.
It’s funny what you say because I would say you have a better chance of your code being upward compatible than downward. It’s the other way around that I have the most trouble with. In general Apple doesn’t get rid of features in newer OS versions (so old code will usually run on newer systems), but they certainly always add something that won’t run on older systems.
Regardless though, in either direction you can have issues. Most programmers will keep older systems around to check to be certain. And if you don’t have older systems then find someone who does and ask them to check it for you. That’s the only safe way to program.
Thanks for your initial replies. The reason I posed the question is that indeed I had run into some difficulties trying this sort of strategy and I assumed that there simply wasn’t any compatibility between versions of OS-X.
You’re comments clearly suggest a more complex plot than that. :rolleyes: I have users who can run some tests for me, and I’ll indeed try some sample scripts and see how “compatible” downward compatibility works out in practice.
These scripts aren’t doing anything particularly exotic and rely on UNIX to do anything particularly difficult like Internet access. So I should be safe - right?
So why do I feel even more worried than before!?!??
With the help of a friend, I’ve been able to answer my own question. A Lion (OS-10.7) AppleScript application will also work on Snow Leopard (OS-10.6). However, at least on a PowerPC Mac, it won’t work on a Leopard computer (OS-10.5).
It is true that a Snow Leopard AppleScript application will also run on even a PowerPC Leopard Mac, however, that won’t run under Lion. So if you have a user community that spans these three versions of OS-X, you’ll need to distribute at least two versions of your AppleScript applications.
Of course precisely what I was hoping to avoid . . . . . .
Well in my expierience I have never met a situation that I needed to write two version of a script due to different OS version (I did for different application versions). I think this what you need to keep in mind when you want to write scripts backward compatible.
Then if it’s about unix utilities you should make a test into your script or include the utility in the script bundle to avoid such problems.
Then at last an example would indicate much more the problems you’re dealing with.
Actually my problem is with the AppleScript stand-alone application format - not the scripts themselves. The scripts run just fine on OS-10.5, 10.6, and 10.7.
However, these scripts run as dedicated applications that query the weather station periodically and then process the data. I was hoping to provide a single AppleScript application that anyone from Leopard to Lion could just double-click on and get started collecting data.
However, it seems that Apple no longer provides the PPC support in the Lion AppleScript application format. Unfortunately, your link doesn’t seem to include release notes for Lion. Are there release notes for the latest version of AppleScript?
I’ve been trying to pursue this angle without success.
What is an “Application Bundle”? Is this something different than a “Script Bundle”? I haven’t been using Xcode, only the AppleScript editor and I sure can’t see how to make something called an “Application Bundle.” Is there a special trick to get the AppleScript editor to include the PowerPC architecture in the AppleScript Application? Can you do this with something like Xcode?
If there were a trick to do this it would make delivering my AppleScript applications much, much easier!
to get the PowerPC architecture included you have to compile the script as an application (bundle) on a Leopard or Snow Leopard machine.
The result is a Universal Binary (for both PPC and Intel), which works on 10.5 - 10.7
In Script Editor you have the save options
script (extension .scpt) - normal compiled script script bundle (extension .scptd) - a compiled script within a file package (similar to rtf <–> rtfd) application (extension .app) - a Cocoa application bundle text (extension .applescript) - the uncompiled raw text
Yes, it is. In the beginning there was a single-file application format for applications. Somewhere around 10.4 or 10.5, the app bundle was introduced as an alternative. The two formats were there in (Apple)Script Editor until 10.7, at which time the older format was dropped – so saving as an app from 10.7 is always saving as a Cocoa bundle. At the same time, support for PPC was dropped.
For your purposes, saving as an app bundle from 10.6 or earlier should work. It will still include the PPC code, but it will be a bundle app, and hence run on 10.7.
With two machine here and some friends I’ve fine-tuned the information you have given me.
Actually the Leopard (10.5) Script Editor has a 5th option:
Application Bundle (extension .app)
The different in Leopard between AppleScript applications and AppleScript application bundles is - no bundle folder so no place to store the resources I was trying to store. This explains why one of my users was getting very strange errors.
The is mostly correct, except that the two different AppleScript application format continue to 10.5 - not 10.6. This threw me for a loop.
Actually it appears to me from my tests that for my purposes I must use the AppleScript editor from Snow Leopard alone (10.6). Anything earlier won’t run under Lion (10.7). The Lion format has dropped PPC support so Leopard won’t work.
I had thought I had tried this technique and had complaints from users of problems. However, I just ran tests and it seems that Snow Leopard AppleScript applications behave just fine on all 3 versions of OS-X. I need to create some more complex tests, but this seems to be the most promising solution I’ve found to providing AppleScripts that support weather station software.
It isn’t that I was planning to use that, but having the same term: Application Bundle for a bit of software technology that once was Carbon and now is Cocoa - sure isn’t going to make it easy hobbyists and other newcomers who aren’t aware of the long history of OS-X transition.
Thanks for adding a crucial bit of my understanding about AppleScripts!
It is not AppleScript itself that is the problem, even compiled scripts have the same binaries on PPC and Intel. That’s also the beauty of interpreted languages compared to languages that will be compiled to machine code. You problem is your applet in the MacOS folder inside your bundle (next with your resources bundle). This very tiny piece of code loads the AppleScript files in the resources folder and executes them. But to run it as an application (process) on it’s own it needs to meet the minimum UNIX/kernel requirements. These requirements needs to be a piece of machine code and is architecture depended. Like Stefan mentioned, you need to make this code an universal binary (ppc, i386 and x86) and Lion’s kernel will pick the right code out of it, like SL and Leopard
How will you know if your script will run on every machine.
Collect the architectures on your machines (open terminal and type ‘arch’ and press enter)
I see i386 and X86_64 on my machines.
Then open the application bundle with the terminal and look which architectures it supports
As you can see that SL will save the script with support for 3 different architectures. Now the application will be supported from 10.5 (ppc and intel) through 10.7 (Intel only). A script saved as an application on a Lion machine misses the last support of PPC code.
For the record: AppleScript has it’s own architecture (OSA) and therefore it depends on it’s interpreter and not it’s processor. OSA itself is not Cocoa or Carbon so they don’t have anything to do with your problem. It is something in the system and not in it’s desktop. Isn’t that one of the purposes of a scripting language… I mean in pure AppleScript you don’t have to worry a lot about the ‘long history of OS-X transition’…
Thank you very much for your help set of descriptions and examples of how to explore AppleScript applications. This is extremely helpful in trying to figure out what machines will be able to run my AppleScripts.
Unfortunately, I need to “rush some AppleScripts out the door.” However, I’ll be returning to these questions soon and if I have additional questions I’ll certainly ask them here.