Creating Universal Binary Distributable files

BlitzMax Forums/BlitzMax Tutorials/Creating Universal Binary Distributable files

Nigel Brown(Posted 2006) [#1]
You will need:

PPC and Intel based MAC's
Icon Composer
Lipo (command line tool)
Disk Utility

1. Build you application on both PPC and Intel based platforms and ensure they are working correctly. If your application uses loadable data then you will need to use “littleendian::” as a prefix to all your ReadFile() and other stream based commands.

2. Next take the two pre-built bundles and create a universal binary from them. An application bundle is not the executable file but a container that holds the executable file and other resources so pay attention to the pathnames. From a terminal window:

Where the following would be the path to Pushy on the Mac Book Pro.

<user> = nigelibrown
<appname> = PushyIntel
/Users/<user>/<appname>/<apname>.app/Contents/MacOS/<appname>

This would be the path to the PPC bundle I have previously copied to the Mac Book Pro.

<appname> = PushyPPC

/Users/<user>/<appname>/<apname>.app/Contents/MacOS/<appname>

So to overwrite the Intel version of Pushy you would use:

Lipo –create [AppPPC] [AppIntel] –output [AppIntel]
Lipo –create /Users/Nigel/PushyPPC/PushyPPC.app/Contents/MacOS/PushyPPC /Users/Nigel/PushyIntel/PushyIntel.app/Contents/MacOS/PushyIntel
 –output /Users/Nigel/PushyIntel/PushyIntel.app/Contents/MacOS/PushyIntel


3. Use Icon composer (spotlight search) to generate associated icons for the bundle. Now you have a universal binary in your bundle you should add your own icons and replace the BlitzMAX versions that are generated automatically. Run Icon Composer and load the icons from:

/Users/<user>/<appname>/<apname>.app/Contents/Resources/<appname>.icns

Create a 128x128 image in a paint package and using file->Import Image add it to the resource or replace the current version. Then drag to all the other sizes in the file 48x48 32x32 etc… you will be asked to auto scale and mask say yes to all. Should give you something like this:

[img ]


4. Finaly use Disk Utility (spotlight search) to create a disk image (dmg) file->New->Blank Disk Image… make sure it is large enough to hold all your files. copy the bundle and any resource / data files that will need to be loaded. Then use convert image to compress it.


JazzieB(Posted 2006) [#2]
<h1>Thanks for this... got my universal binaries sorted in no time at all.

Just a shame you end up with a file twice the size if you include all your media via IncBin :o( Different strategy required for media and Mac, me thinks. Hmmm....</h1>

Last edited 2010


JoshK(Posted 2008) [#3]
What is a universal binary distributable?


Gabriel(Posted 2008) [#4]
One that works on both PowerPC macs and the newer Intel Macs natively.


ImaginaryHuman(Posted 2008) [#5]
A universal binary is Apple's attempt to simplify for users the fact that Macs now run on two different processor families and thus needs a specific binary compiled for each cpu. So the universal binary contains executable code for both Intel X86 and PowerPC cpu's and MacOS knows how to use it on a given hardware platform ie which code to run. Usually when you use a universal binary, since your executable is in there twice, you would normally NOT use incbin's in your code, and instead have all your data stored in files that you load, otherwise you would continue to double the space consumed. It's meant to make it easier to distribute and to install, ie forget about what CPU you have.


boomboom(Posted 2008) [#6]
I am a little stuck on point 2. I have 2 folders now at:

/BBGBuild/PPC/
/BBGBuild/Intel/

Each folder contains the relivent compiled executionable and the media. How do I make a 'bundle' for each of them before then continueing with the rest of the guide and making the 2 bundles into a univeral binary?

Sorry, I am a complete Mac noob.


boomboom(Posted 2008) [#7]
ah I got it. I quite like how mac packages stuff up like that! especially when you can go inside the package and edit things so easily.


JazzieB(Posted 2008) [#8]
If anyone wants to know how to include their data within the application bundle so that it can be shared by both the PPC and Intel binaries (so that you don't end up with a file twice the size when using Incbin, or are forced to use an external folder), then I have produced a guide here. Why this has not been made a sticky, I don't know. Anyway, it's there if anyone needs it.