views:

881

answers:

6

I want to keep my app under 10.0MB for easy downloading in both cellular and Wifi network environments. In your experience have you come across any good ways for keeping your apps slim? If so please share. What are some good guidelines for keeping iPhone app file-size under 10.0MB?

+2  A: 

One tip would be to use compressed media formats. E.g. if you are using audio files you could consider using mp3 instead of AIFF or WAV, at the possible price of a slightly higher processing overhead. A 10mb executable sounds unusually high so maybe an app that big would contain a lot of media content (images, audio).

moigno
+4  A: 

Most apps I've dealt with that go over 10M are due to resources, often images and audio. Correctly sizing these them is critical. Note that iPhone does some compression for you automatically when bundling for the device, so the size of things in Simulator can be radically different than on device.

Like all optimization exercises, you want to build a solid, sane system first and then focus your optimization efforts on the pieces that are causing the biggest issues. I use du for this:

  • Build for the device in Release
  • Go to build/Release-iphoneos/.app
  • du -ak | sort -rn | head

This will give you a list of where the top things are. This information is in kB, but is rounded up to the next block (4k on Mac). But you're just looking for what's big, not working out the exact size of everything.

Look especially for things being copied into your Resources that shouldn't be. Funny things sometimes get in there, especially documentation that you've added to the project. Testing this out, I notice that my own project template has been copying xcconfig files into the bundle (gotta fix that...)

If you have lots of localized NIBs, then you may want to consider not localizing the NIBs, and rather using IBOutlet UILabels. Don't localize a NIB if there's no actual localized text. Just because you localize one NIB doesn't mean you have to localize all of them.

Generally the build settings for iPhone are already aggressive in getting the size down, so I wouldn't mess with that a lot without researching what you're changing.

Do watch out for Objective-C classes with many methods that you never call. Objective-C is dynamic, so you can't do dead-code stripping on it like in C. There's no way to know at compile time whether a selector might be used at run-time. So if you have objects that have the kitchen-sink in them "just in case," you may want to strip those down. But generally we're not talking about a lot of space here compared to a single audio file. I only mention it for the rare case where you have a really huge object that you only link for some class method or constant or the like.

Rob Napier
+3  A: 

Another tip: Be careful with your 9.9MB app!

You don't want to discover after lots of optimizations that your app appears to be 10.1MB.

Kriem
A: 

The build process automatically compressed PNG files for you (using pngcrush, do not do that yourself), so actually you'd have to have quite a lot of assets to get over 10MB is size. I think worrying about this is a premature optimization and you probably do not need to be concerned until you find yourself getting close later.

Kendall Helmstetter Gelner
A: 

Convert a few of your larger images to grayscale if it will work with your app's look. If you can make a few purely grayscale, the savings is pretty substantial.

Kelly
A: 

This tipos will mostly apply to iPhone games:

  • Use JPGs instead of PNGs for images that don't have transparency.
  • Have your sounds in mp3, render them to WAV the first time the app is loaded and save them to the app Documents dir.
Marco Mustapic