Wilcox Development Solutions Blog

Universal, 10.3 and up Applescript Studio application

January 25, 2006

Introduction

Today I worked on making Helix Maintenance Manager, a universal binary. HMM is an AppleScript Studio application which needs to target Mac OS X 10.3 as well as Mac OS X 10.4. Since the steps to create an application under these exact situations seem to be helter-skelter, I’m combining them here, for a simple one, two, three checklist.

Something to note is that this app has a few Objective-C/Cocoa routines along with the AppleScript. Some of these steps might be irrelevant for ASK applications that have only AppleScript in them. On the other hand, I’m betting a great number of ASK applications include a few Objective-C/Cocoa routines anyway. I also started with an XCode “native” target, so if you are upgrading from say ProjectBuilder, you’ll need to Upgrade your Target to Native.

Targeting versions of Mac OS X earlier than 10.3.9 with your PPC builds is an easy thing, but you’ll need to use a different compiler (gcc 3.3 or lower) for your PPC builds, while using GCC 4 for your Intel builds. 10.3.9 is compatible with GCC 4.0, so if you’re only targeting that version, you can get away with the same compiler for both architectures. This article won’t touch on how to do that, but the [Cross Development article from Apple’s Developer Website](Cross-Development Programming Guide: Cross Development and Universal Binaries) does mention this setting.

Step 0: Make sure you have XCode 2.2(.1)

This is very important. None of these steps will work if you don’t have at least XCode 2.2 - I know this from experience. XCode 2.2.1 got released earlier in January, so you might as well grab that update from connect.apple.com, if you need to update from XCode 2.1.

Step 1: From Universal Binary Programming Guidelines: Building Your Code

Make sure you have a Native Target

Click on the Target and check to see if the “Upgrade… to Native Target” item is enabled or not. If your project is dated (we started HMM back in the ProjectBuilder days), then you might not have done this yet. If you don’t have a native target you can’t build universal binaries!!

No, really, make sure

Open up the Targets outline item in the project window. The native target badge looks like an application with a green checkbox, while the non-native targets’ badge looks like a bullseye. Save yourself some grief and make sure. Pretty picture:

nativeVsNoneXCodeTarget.png

Set Architecture type to ppc + i386

You’ll need to tell XCode you want to build for two architectures. Double Click or Get Info one your project and go to the Build tab. Double-Click on the “Architectures” static text, which brings up a nice little “check the architectures you want to build for” dialog box. Select both ppc and Intel.

If you just want to support 10.4, you could select the MacOSX10.4u.sdk in the Cross-Develop Using Target SDK popup. That should be it.

Step 2: From Cross-Development Programming Guide: Cross Development and Universal Binaries

Choose a target SDK

Since we want to run HMM on 10.3 as well as 10.4, we need to specify a different SDK for PPC builds (10.3) than Intel builds (10.4). This is simple with XCode 2.2: use the MACOSX_DEPLOYMENT_TARGET_($arch) capabilities.

For PPC

In Project Info, Create a new build setting (the plus button at the bottom of the list of settings). Give the setting a name of MACOSX_DEPLOYMENT_TARGET_ppc, and a value of 10.3.

Create another build setting for SDKROOT_ppc, which will point to your 10.3 SDK (either enter /Developer/SDks/MacOSX10.3.9.sdk, or you could have dragged the SDK into the edit field to populate that value with its path)

For i386

Using the same steps as above, create the following build settings:

  • MACOSX_DEPLOYMENT_TARGET_i386, set to 10.4
  • SDKROOT_i386, set to /Developer/SDKs/MacOSX10.4u.sdk

Do a Build of your Deployment Target

Now, make sure your Deployment Build Config is active (“Set Active Build Configuration” from the “Project” menu), and Build your target

If your one of those people who geeks out over the Build Log, you can examine it to make sure your application is building as universal. You can do a Find for “i386” and you should get at least one occurrence of that search string.

In the Finder, the Get Info window for your app should say “Kind: Application (Universal). Congrats, you are done!

Summary (based off steps by Mark Butcher on the Applescript-studio mail list)

A summary of the requires steps is:

  1. Use Xcode 2.2
  2. Upgrade the project to native
  3. Select both PowerPC & Intel for the architecture.
  4. Turn the prebinding build setting off [Ed: I’m not so sure about this. I turned it off anyway]
  5. Select the proper SDK for the proper architecture
  6. Clean and Build

Conclusion

Now you should have a universal, OS X 10.3 and higher AppleScript Studio application. Happy building, campers!


Written by Ryan Wilcox Chief Developer, Wilcox Development Solutions... and other things