Search code examples
iosobjective-cxcodellvm-clang

iOS app binary doubled in size in Xcode 5


My iOS app needs to be very small in order to be downloaded at events with low cell reception and no wi-fi. My app used to be 1.8 MB on the App Store, and it took me a long time to get it that small. The binary itself (inside the .ipa file) was 1.6 MB uncompressed.

I built the latest version of my app in Xcode 5, and all of a sudden the binary itself is much bigger. The app is 3.9 MB on the App Store. The binary itself is 3.4 MB uncompressed.

I haven't changed my build settings, nor my targets (armv7 and armv7s only). The code is mainly C++ but also Obj-C.

Why would this happen?


Solution

  • I had the same problem with our game after upgrading to Xcode 5. Using file and otool I get the following results:

    Xcode 4 build

    > file Game.app/Game
    Game.app/Game: Mach-O executable arm
    > otool -h Game.app/Game
    Game.app/Game:
    Mach header
          magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
     0xfeedface      12          9  0x00           2    29       3332 0x00218085
    

    Xcode 5 build

    > file Game.app/Game
    Game.app/Game: Mach-O universal binary with 2 architectures
    Game.app/Game (for architecture armv7): Mach-O executable arm
    Game.app/Game (for architecture cputype (12) cpusubtype (11)):  Mach-O executable arm
    > otool -h Game.app/Game
    Game.app/Game (architecture armv7):
    Mach header
          magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
     0xfeedface      12          9  0x00           2    32       3588 0x00218085
    Game.app/Game (architecture armv7s):
    Mach header
          magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
     0xfeedface      12         11  0x00           2    32       3588 0x00218085
    

    To prevent Xcode 5 from building a fat (both armv7 and armv7s) binary, go to Build Settings for the target and set the Architectures entry explicitly to only armv7 (the default is $(ARCHS_STANDARD)).