Given that hard drive size is rarely a concern anymore, developers seem to make an assumption that space is no longer a issue. Despite this, a common complaint in forum posts is a lack of hard drive space. Although the following tip won’t solve all space issues, it can be a valuable part of the process of conserving and freeing up space if needed.
Applications for OS X are commonly distributed as application bundles which, to be fairly blunt, are little more than glorified folders containing the application binary and required resources such as icons, artwork and related documents (help files for instance). This has one major upside and an accompanying downside: the application is self-contained which means everything required for operation is in one folder but this means that the application bundle itself can be larger than necessary. This problem becomes more evident when developers bundle the PowerPC and Intel versions together (universal versions). Although universal binaries are not automatically twice as large (both the PowerPC and Intel version share the same resources – artwork for instance can be loaded on either platform without change), the size is larger given that two binaries have to be included. This “issue” is not limited to universal binaries either – some developers now bundle 32 and 64 bit versions of their applications together. As an example, the development builds of the Opera web browser now ship as a “universal 32/64bit binary.” Much like the “old” universal binaries however, all users only need one of those versions. Thus, part of that application bundle is left sitting there doing little but consume space.
The Diet Plan
Various tools are available to do this but one simple tool is already included with OS X. The tool is called ditto, which among various other features, “can be used to ‘thin’ Universal Mach-O binaries during a copy” (source). In essence, the tool works by creating a new copy of the application bundle that contains only the binaries for the platform that you specify.
To use this tool, we need to execute it from the command line. Don’t be scared off – the process is quite simple. First, open up Terminal (/Applications/Utilities/) and enter the following:
Next to that, you have to type in the architecture that you want. In other words, if an app is a 32/64bit binary and you only want a 64bit binary, you need to specify that after the “–arch”:
ditto --arch x86_64
If you want a 32bit version, use the following:
ditto --arch i386
The next part is the name of the application itself. You can add this to the command easily by opening Finder, locating the app and dragging it into the Terminal window. Your command should now look like something similar (an example is coming to make this more clear if you don’t understand):
ditto --arch <the arch you chose> <the application>
Now, we only need one more piece of information. The final piece is the name of the new app bundle. You need this because ditto makes a copy of the app and doesn’t modify the original. This is the beauty of ditto – you get a copy and if it doesn’t work, you still have the original app bundle. In essence, it forces you to have a back up. Your command should now look like the following:
ditto --arch <the arch you chose> <the application> <the new application>
Let’s take a look at an example.
It’s Over When the Thin Man Sings at the Opera
As I noted above, the next version of the Opera web browser will ship as a 32/64bit binary for the Mac. This allows them to ship one version of the application that will work on all Intel Macs and won’t require that the user know whether or not they need a 32 or 64bit binary. As a big Opera user, I have decided to use this for the purposes of my example (it also gave me a chance to use that really bad joke for the section title).
First, I open up Terminal and start the process of crafting the command:
Next, I determine what architecture I want. Owning a Mac with a 64bit processor, (if you don’t know whether or not you have a 64bit machine, take a look at this) I decide to strip out the 32bit resources:
ditto --arch x86_64
Next, I drag the application bundle into the Terminal window and get the following:
ditto --arch x86_64 /Applications/Opera\ Next.app
Next, I determine a new name and location for my application. I decide to call it “Opera Next Thin” and append the appropriate information to the end of my command1:
ditto --arch x86_64 /Applications/Opera\ Next.app /Applications/Opera\ Next\ Thin.app/
Press enter and give ditto a moment or two. Once that’s done, you’ll notice that you have a new application bundle that has been thinned. For me, the results were noticeable as you can see:
Here, I managed to trim off 45.2MB which means that the application bundle is now 36% of its original size!
You’ll also note, as I mentioned earlier, that the original application bundle is still there. Keep it around until you’re absolutely sure that the new bundle works for you.
1 Note that there is a \ just before the spaces in the names of the applications. Bash (the command line) requires that you put a \ before a space in the names of files and folders.