10

My iPhone app is getting ready to go to production and we like to cram in as much data as possible. When I poke around the generated .app file for my application I see a file named <executable name> which I assume is the compiled code. It is about 2.5 megs which seem large for what I am including in my app. What type of things should I check to make sure there aren't any unneeded items being included into my executable?

2 Answers 2

5

There are a number of things you could do -- 2.5 MB is a small app.

  • One obvious way is to verify that your binary is in fact stripped. This removes unused references (e.g. functions which are not actually called) and debugging info.

  • Link Time Optimization (LTO) can save you a ton of space, although that applies to the C and C++ aspects of your program. It brought one of my programs down to about 1/5 the size.

  • Play with optimization settings. O3 and O2 often produce a smaller binary than Os.

  • Keep track of your dependent libraries. Their exported symbols may be relatively large.

  • Favor C or C++ for shared libraries in larger projects. If unused, they may be stripped or optimized away.

  • Minimize static data and static functions, restricting their scope to the c, cpp, m, mm file.

2
  • I guess I know that general idea but how would I go about doing that in Xcode? I was hoping someone would tell me some settings in <Double-Click Project> -> Build that I could mess with.
    – TurqMage
    May 16, 2011 at 15:55
  • there are several strip options, not all will apply. just go to the target's build settings panel and search 'strip'. you don't want to strip the debug builds.
    – justin
    May 16, 2011 at 17:39
2

I probably wouldn't be overly concerned about the app being 2.5MB, but if you want to do due diligence in making sure you're only including what is really needed, I'd take a look at all of the resource files (images, views, movies, etc) that your project references and make sure that all of them are being used by the application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.