The reason for this article should be obvious: too many OS X third party developers do an absolutely terrible job of building and packaging their applications. rixstep
Too many apps are shipped with debug symbols, uncompressed images, redundant files or generally useless rubbish that not only wastes users’ disk space, it ultimately ends up increasing the developer’s own bandwidth costs.
It’s not just the script kiddies at fault. Path Finder weighs in at over 60 MB on disk, but after a few simple operations, is halved in size to just over 30 MB. AppZapper can be trimmed from three megabytes to just one. Xslimmer (ironically) is over 80% junk, going from 5 MB on disk to a meagre 1 MB after being cleaned. In this case, the disk image is three times as big as the cleaned, uncompressed app. Starting to see the trend? Almost every app can be cleaned up to save a good deal of space.
Deploying your app
Rixstep provide instructions on deploying OS X apps covering most of the major areas.
Essentially, you need to:
- Remove Junk
- Get rid of all .DS_Store files. In Cocoa apps, remove PkgInfo. You should only have objects.nib or keyedobjects.nib in your nibs: remove classes.nib, info.nib, and data.dependency; these are not relevant for the user. Also remove all header files from your app and from embedded frameworks.
- Clean up localization
- Keep all non-language-specific resources in the Resources folder rather than duplicating them in each .lproj folder. Look through the framework you’re embedding, and remove any unnecessary files files. That includes language projects which your main app doesn’t support.
- Compress images
- Make sure all your images are compressed, especially if they’re in TIFF format. (But you shouldn’t use images for simple graphics like curves or gradients anyway; there are Cocoa drawing routines for that and NSBezierPath is your friend)
- Trim binaries
- Do not release an app that has been built using the Xcode “Debug” configuration. Remove the debug symbols from your build product, and if possible, release architecture-specific versions of your app, as well as a universal binary.
Get all the details in Building and Packaging Native OS X Applications.
Automation
A relevant question is: are there any tools that automate this process? And the answer has to be ‘not up to now there aren’t’. Until something comes along to save users from these issues it’s still all up to that developer you trust. Rixstep
There is finally a tool that automates at least some of the cleaning process. Say hello:
Trim-app is a shell script. It:
- Cleans out all the horrible .DS_Store files
- Removes unnecessary info.nib, classes.nib, and data.dependency files from inside nibs
- Strips “fat” universal binaries to contain code for a chosen architecture only
- Eliminates debug symbols that may be left in your application
You can perform all procedures at once, one at a time, multiple at a time, etc. using different parameters or flags (run trim-app -h for help).
The script searches the current working directory including every subdirectory so no files are missed. Even embedded frameworks are scanned through and cleaned out. So make sure you’re in the right directory before running (use the pwd command if unsure)
All changes performed are permanent and non-recoverable. (If you’re writing the app, that shouldn’t be a problem. Just build it again if something goes wrong)
While it’s written for cleaning out applications, this script is also great for general tasks - cleaning out .DS_Store files in a certain folder, for example.
Installation
- Unzip the download.
- Open Terminal and navigate to the folder where the unzipped trim-app is.
- Run
chmod 0700 trim-app. This makes sure only you can execute it.
If you want easy access to the command, move the file to /usr/bin/ by running sudo mv trim-app /usr/bin/. You’ll be asked for the admin password, then file will be moved.
You can now test if it’s working by running trim-app -h. Instructions for trim-app will appear. Once you’re done reading them, press q to exit, and start using it!
Usage
Running the shell script without any parameters will attempt to run all four procedures. You’ll be prompted for an architecture to keep in universal binaries. Leave this blank (just hit return) to leave universal binaries universal, or type in an architecture to keep (usually ppc or i386) if you want them stripped down.
Here’s an example of how you would use it in the Terminal:
% cd myApp.app/
% trim-app
Architecture to keep? (ppc/i386) ppc
Removing .DS_Store files…
Trimming nibs…
Trimming universal binaries…
Stripping debug symbols…
Cleaning up…
Done.
%
If you don’t want to be prompted each time for the architecture, use either --all (as in, trim-app --all) (which will run everything except the liposuction of universal binaries), or add the architecture to keep immediately after, like trim-app --all ppc.
Add a -p flag to the end if you want to see a list of affected files. For example,
% trim-app --all i386 -p
You can also run individual procedures. The following cleans out .DS_Stores from the entire Macintosh HD:
% cd /
% sudo trim-app -d
Run trim-app -h to find out more about the available parameters.
Don’t forget the standard shell practices still apply. Ctrl-C any time during operation to immediately halt execution, save output to a file with trim-app -p > trim-log.txt, and so on.
Lastly, remember that while this shell script does a lot of the work (and there is an application called CleanApp which can help remove unnecessary lproj files), it’s still up to you to take care of removing headers, compressing images, etc.
22 Comments so far
Leave a commentGood job!
Is it possible to use with downloadede application? If i’m not a developer - can i put some app on diet with help of trim-app
P.S.
I like it too. But what is comment live preview addon name?
Markdown is good choice
reasonded by NilColor on September 19, 2007 9:20 pm | Permalink
You can use it on apps you download. I’ve recovered a few gigabytes by cleaning up my Applications and Library folders.
However, a few apps either don’t work or prevent the application from running if the binary has been modified (to prevent cracking, I guess). I’ve only come across three - Typeset, Speed Download and Skype. In these cases, you can still run trim-app, but just leave the apps as universal binaries.
If you want to recover space, I’d also suggest removing extra .lproj folders, and just keeping the one (or two) main language that you use. CleanApp is a pretty quick way of doing this.
The comment preview is using a javascript implementation of Markdown called Showdown.
stated by Ankur on September 19, 2007 9:50 pm | Permalink
Hmm - magically free up disk space? Ok - your mileage will vary. Path finder only reduced by 200K for me - keeping i386, not PPC. Linotype Font-explorer halved from 25MB to 12MB, but broke - does not like being tampered with and says so
Other apps (Transmit, Textmate, Studiometry 3) are only losing 100K-2Mb.
Nice script, but I’m not sure you can rant that Mac Developers are the slackers you think they are
proclaimed by Vish Vishvanath on September 20, 2007 7:42 pm | Permalink
Vish, I ran trim-app on Path Finder keeping i386, and it reduced from 62.1 MB to 38.1 MB (physical size). Another 10 or so MB can be lost by removing language projects and such. You might be running the script on just the binary for it to reduce by only such tiny amounts. Try:
And I’m not saying Mac developers are slackers, but it is surprising that bloated apps exist given the expertise of many developers.
determined by Ankur on September 21, 2007 8:09 am | Permalink
Oh this is good stuff. We’ll try later - today hopefully. You should have written!
announced by Rick on September 22, 2007 2:56 am | Permalink
@Ankur:
‘I’m not saying Mac developers are slackers’
OK - but we are. They know about this - and just don’t give a damn. Look inside PF and you’ll see a lot of ‘incomplete’ resources. Start with the InfoPlist.strings files. Another thing missing - possibly impossible to automate in this fashion - is compression of TIFFs. This can fortunately be done today by Apple’s Preview. And we do have a command line tool for this purpose. For an obnoxious example of this see the following URL. It’s a 32×32 TIFF - and you can adequately guess about how big it should be (about 2 KB tops). The software author - several years an Apple developer - got it somehow to the staggering 357284 bytes. And since he left Apple he’s updated the program and the eyesore image remains.
http://rixstep.com/4/2/podworks,00.shtml
It’s not surprising to us. Apple do a good job as we pointed out. What’s also surprising is that 3rd party do not emulate Apple more - what this points to is your call. It’s certainly not concern about consumer satisfaction.
announced by Rick on September 22, 2007 7:51 am | Permalink
Ankur: you seem to reduce the apps quite a lot, but are you sure you aren’t removing .DS_Stores that were put there by yourself?
proclaimed by sphynx on September 22, 2007 10:47 pm | Permalink
Thanks Rick!
Sphynx,
Yeah, I’m fairly certain. I don’t use Finder
recorded by Ankur on September 22, 2007 10:55 pm | Permalink
“if possible, release architecture-specific versions of your app, as well as a universal binary.”
Please! Do not do this, Macs are supposed to be easy and seamless.
written by James on September 23, 2007 5:19 am | Permalink
I disagree with you there, James; providing extra downloads is more of a courtesy than a hindrance. Obviously the main download should be the universal package with all the languages and what-not, but providing localized builds is quite useful for many users. Many big companies do this as well, and it makes sense - why download an application with twelve different languages and two architectures when you can do with one of each? It saves bandwidth for both the user and the developer (but users who don’t know the difference don’t have to worry about it).
So I don’t see how “easy and seamless” is affected by any of this…
written by Ankur on September 23, 2007 10:52 am | Permalink
Groan!
revealed by Rick on September 27, 2007 7:03 am | Permalink
Apropos: we finally took Xslimmer apart. I know we mention it somewhere but we never opened it up before. First we thought your estimate of 80%/4 MB bloat was a bit high but then we looked a second time: the dorks also duplicated Resources directories!
Just in case someone here isn’t following along: Xslimmer is supposed to slim your apps on disk - it’s supposed to be part of the solution, not part of the problem.
Yet when applying Xslimmer on itself it gets about 3 MB of the 4 MB we’ve found and misses an entire meg. And remember: this is Xslimmer running on itself. So the people who want to help you eliminate waste from your HDDs just dropped a 4 MB elephant do-do on you when you weren’t looking.
But here’s another thing that happens when you’re not looking: Xslimmer automatically copies itself to /Applications if you don’t put it there. Reboot and 6 MB are missing? Look in /Applications.
Lovely stuff.
This is another one that sells itself not on its performance but on its slick look and the look of the accompanying eponymous website.
Register a domain. For a single software product. Concentrate on the packaging, not on the performance. Maybe run some exclusive beta tests. Get your five stars from Version Tracker. The quality? Who cares about quality?
divulged by Rick on September 27, 2007 7:09 am | Permalink
Yeah, I thought that was quite a nice touch. Why embed just one framework when you can have three of each!
Wow, I didn’t notice that.
Absolutely
revealed by Ankur on September 27, 2007 9:53 am | Permalink
Nice work Ankur. You’re right about most Mac apps being bloated - I’ve saved at least a gigabyte with your fantastic trim-app script.
stated by Harley on October 1, 2007 6:56 pm | Permalink
If everyone was still on dial up service with a 2400 baud modem this is stuff people would already be doing.
recorded by Brian on October 18, 2007 11:55 pm | Permalink
One reason that we ship universal binaries is that in the back of my mind I think that the user might take my app out of their /Applications folder and copy it to another computer or onto a shared location for other users. I believe that users should be able to do this and not worry about the binary being stripped. If I thought disk space was so important that universal binaries should be stripped, then I would have an installer script do it. But disk space isn’t that scarce. My app’s executable is actually very small, but it is about twice the size of the Windows version. To me, its not a big deal. We have big disks today and this app is about the size of maybe 1 mp3 song. Uncompressed artwork, I do have sympathy for that argument.
declared by Brant Sears on October 19, 2007 3:49 am | Permalink
Brant,
Nope. The way I see it, if the user is able to ignore the main (universal) download link and find and download an architecture/language-specific build, they’ll know what they’ve downloaded.
Which is why I said before that the main download link should be universal, but there should be at least an option for localized builds even if its (figuratively) hidden away somewhere.
recorded by Ankur on October 19, 2007 4:22 pm | Permalink
thank you so much for this article… its about time someone said this
stated by adriana on November 3, 2007 4:31 am | Permalink
So how can I clean my WHOLE Mac at once (10.4.11) AND THEN discover the parts that hate the idea and wont work unless they are re-hired?
recorded by Me2 on December 31, 2007 8:22 pm | Permalink
If you want to do that, find the shell script ‘trimmit’ inside Trimmit.app/Contents/Resources (Download Trimmit). You can copy that out and use it. The only thing to be aware of is that you must provide FULL paths. That is, rather than Desktop, /Users/name/Desktop/. Example:
d - delete junk
t - compress tiffs
r - remove resource forks / extended attributes
b - keep backup copy (recommended)
s - strip debug symbols
-a architecture
and -l list of languages separated by “|” (en will match en and english, En will match English).
But please note I’m providing this information without any guarantees or liability. There’s a high chance something will stuff up.
As for determining which apps might get messed up, there’s also a list of apps that don’t like being cleaned in the readme for Trimmit.app. However, you can only find out once you try to run them, but if you use the “-b” option to make a backup, that is guaranteed to still work as it did before.
mentioned by Ankur on January 2, 2008 11:34 am | Permalink
Leave a comment