Creating Cross Platform Windows and Mac Installer CDs

I'm working on an Adobe AIR cross-platform app at work. We're providing a physical CD for distributing the application and I wanted the CD to work like a real Mac CD should look like -- Background image in the finder, hide all extraneous files, auto-open the finder window when the CD is inserted, etc.

Getting just this to happen requires some trickery, and getting it to happen while also putting an auto-launching Windows installer on the same disc proved to be even more of a game.

After a lot of googling I think I've got a pretty good process down and wanted to share, so here are the details.

Core Concepts

  • The standard ISO CD filesystem doesn't let you do all the good stuff that you'll want to do for Mac (finder background image, hiding files, etc). You need to use some variant of HFS. However, Windows can't read HFS.
  • 'Hybrid CDs' solve the previous problem. From what I understand, a hybrid CD contains an HFS volume and a standard ISO volume. Windows machines can't see the HFS volume and OS X machines ignore the ISO volume when there is an HFS volume present.
  • You'll need the OS X Developer tools for these steps
  • From what I understand, Roxio Toast 7 & above make this much easier, but this is more fun and it's free. :)
  • It is much easier to test all this out in Windows if you have Parallels (or presumably Fusion) because Parallels let's you mount an iso in Windows as if it were a CD, so you don't have to waste your precious blank CDs creating actual copies. :)

Steps

  1. Create a standard folder on your harddrive and put all the install files (windows and mac, including an autorun.inf for your Windows installer, presumably) in it. We'll call it 'install folder' for now.

  2. Make a user-friendly finder window

    To make a nice OS X finder window for a CD (or dmg or whatever) we want to have a friendly background image that helps the user understand what they're supposed to do. Go grab AdiumX to see an example of what I mean. We have to include this image on the CD, but we also want to hide it from the end user so that it doesn't clutter up our install window. Here are the steps:

  3. Create your background image.
  4. Create a folder called 'background' inside 'install folder'.
  5. Put your background image into this folder.
  6. Use terminal to rename this folder to '.background'. e.g.: mv background .background (The folder should then disappear from view in the Finder)
  7. Open 'install folder' in the Finder and hit Command+J. Make sure that 'This window only' is selected. Click 'Picture' for the background. In the dialog that comes up, hit command+shift+g to bring up a box where you should enter the path to your '.background' folder. This allows us to navigate there even though it is hidden. Select your background image and click OK.
  8. Click 'Picture' again for the background. For some reason it gets reset after selecting the picture.
  9. For each file that you'd like hidden in both windows & mac (e.g. perhaps the window autorun file), run this command in Terminal:

    `/Developer/Tools/SetFile -a V /path/to/your/folder/name-of-file-to-hide`
    
  10. Get rid of the finder toolbar (click that top-right oval button) and resize your window & arrange your icons, leaving the windows icons clumped together somewhere for now (we'll hide them in a minute)

  11. Create the hybrid ISO using hdiutil Run this command in Terminal to turn your folder into a hybrid ISO:

    hdiutil makehybrid /source/folder/name/ -o outputfile.iso

  12. Mount the ISO in read-write mode: Run this in terminal:

    hdiutil attach -readwrite outputfile.iso

  13. Make files invisible to Mac ONLY (e.g., your windows installer file) by setting the invisible bit on them: Again in terminal:

    /Developer/Tools/SetFile -a V /path/to/your/folder/name-of-file-to-hide

  14. Make the finder window auto-open when the cd is inserted/image is mounted: In Terminal:

    sudo bless -folder "/Volumes/discName" -openfolder "/Volumes/discName"

  15. Test it out. Mount your ISO and unmount it a couple times to see the wonderous installer. If you have Parallels you can try it out in Windows too by using 'Connect Image' to simulate it as a CD in Windows

  16. Open Disk Utility & drag your iso file into the left-hand pane. Click 'Burn' in the toolbar above. Insert a blank CD and let it burn.

Done! Try inserting it into a Mac and a Windows machine and be amazed by the beauty of it all.