Update: apparently this has also been discussed in the Unity forum and they reached about the same conclusion. It also shows more evidence that Unity Apps are hit pretty severely by the loss of compression due to the encryption process, 4-5 MB was what most users reported with some even much more than that.

I’m working on a calculation to at least determine the upper size of an App after Apple has had a go at it after a successful approval.

First of all we need to understand what Apple adds to the .app bundle after approval. I found a post that sums up the files that are added by Apple:

“additions are the iTunesArtwork file (70k), iTunesMetadata.plist (2k), files in the new SC_Info folder (12k) and the updated CodeResources file (9k)”

All in all about 100 KB in additional files. So where’s the rest of the bloat coming from? After all, some people even report an increase in size after approval of several Megabytes!

The answer is surprisingly simple: Apple is encrypting the executable file. By doing so its size doesn’t change much but its contents do which usually can no longer be compressed as much as before. By putting all this together i came up with a way to calculate the maximum size of your App in the App Store (it will most likely be less than this):

  1. open the .app bundle via right-click -> Show Package Contents (on Mac)
  2. locate the executable file and remember its (uncompressed) size (Size “A”)
  3. delete the executable from the bundle
  4. zip the bundle and remember the bundle’s compressed size (Size “B”)

Size “C” are the 100 KB from the additional files added to the bundle by Apple. The final calculation for the maximum size of your App is as follows:

A + B + C = maximum size of your App after approval

The calculation put in words:

(uncompressed executable size) + (app bundle compressed but without executable) + 0,1 MB = maximum size of your App after approval

I only have one App (51 Japanese Characters) in the App Store right now, so i can only test it with this App. The submitted App is 3,9 MB zipped and 4,3 MB on the App Store. The executable file is 1,0 MB and the App compressed without the executable is 3,6 MB. By my calculation i get:

1,0 MB + 3,6 MB + 0,1 MB = 4,7 MB

That is more than the 4,3 MB the App’s actual size on the App Store but remember: we calculated the maximum size the App might have. Depending on your code and more likely the engine you use (i use cocos2d exclusively till now) the amount of compression lost by Apple’s encryption varies greatly. Especially if assets (images, sound, music) are embedded in the executable (so don’t do that!). I hear that Unity iPhone applications can suffer a great deal more, however i don’t know if there was anything particular about the App nor which version of Unity iPhone was used, so take it with a grain of salt.

Now, how can we get closer to reality with this calculation? By introducing a good (upper) value for how much the executable file can still be compressed after encryption. In the case of 51 Japanese Characters it amounts to about 60%. So if we modify the calculation with a compression factor “F” we get:

(A * F) + B + C = maximum size of your App after approval

In the case of 51 Japanese Characters F would be 0,6.

I would very much appreciate it if you could do the calculation with your app(s) and post your results here. I’m most interested in your value for F, the more reports we can get the closer to the (mean average) compression factor for the encrypted executable. At this point i can only say it’s 0,6 in this particular case but it might as well be 1,0 for other Apps. Please post your results here!

Tagged with:  

8 Responses to How to calculate the final size of an iPhone App before approval

  1. […] How to calculate the final size of an iPhone App before approval […]

  2. Justin says:

    Haven’t submitted mine yet but have a question —

    When I build an archive to distribute to beta testers, it’s 11.2MB

    When I look at doing the calculation your way, the executable is 12.2 and the zipped content is 6.9 which gets my total just under 20MB.

    Why is that nearly double the size of the .ipa?

    • Justin says:

      Well let me clarify — I understand that the increased size is due to the executable being uncompressed… but what I’m curious about is why I can distribute a fully compressed file to beta testers and have them install from a web browser using Test Flight but when downloading from the App store, they’ll have to download a bigger file. Seems like a waste of bandwidth on Apple’s part.

      • If I remember correctly, the executable IS compressed. But it is also encrypted, which effectively makes it near uncompressable because all compressible patterns of data have essentially become random noise. That’s the point of encryption, to make data seem like noise with no way to turn it back into data unless you know how to decrypt it.

        The IPA format remains the same, which is just a zip file with the IPA extension.

  3. Chen Li says:

    I made Lola Sudoku game, the result by using the function is 17.7 and actual size is 16.6. Thanks for the info you shared.

  4. Ray says:

    An app of ours that recently ot accepted came up to 18 mb, when the original .ipa file was only 9.6mb. We calculated a value of 0.96 for the F factor… At least now we know why

  5. James says:

    GroHabit, my personal development app for creating new habits, is 1.5 MB on the App Store. A = 1743 KB, B = 802 KB. If my calculation is correct, F = 0.343.

    That number seemed small to me. So, as a test, I compressed the unencrypted executable and got it down to 526 KB, which is an F of 0.3. That makes sense. I would have been very suspicious if Apple could get better compression by encrypting first.

    That doesn’t change your upper bound for F, but I figured I’d add my results to the set. It does seem to imply that using F = 1 or even F = 0.6 could results in a significant overestimation. (Obviously it doesn’t matter much for me since my app size is small.)

  6. […] this post for details: http://www.indiepinion.com/steffenj/how-to-calculate-the-size-of-an-iphone-app-after-approval/ Tagged: armv6armv7questionsXcode /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING […]