Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some good guidelines for keeping iPhone app file-size under 10.0MB?

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?

like image 638
RexOnRoids Avatar asked May 28 '09 06:05

RexOnRoids


1 Answers

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.

like image 149
Rob Napier Avatar answered Nov 15 '22 12:11

Rob Napier