Game size CHECK under 10mb

Discussion in 'iOS Development' started by bergerbytes, Feb 4, 2010.

  1. bergerbytes

    bergerbytes

    New Member

    Joined:
    Sep 19, 2009
    Messages:
    139
    Ok, I know this topic has been beat to death but I'm not so worried about getting it under 10 but I really want to know how to check the size of the game before it's on the app store.

    Thanks,
    -Mike Berger
  2. bliprob

    bliprob

    Member

    Joined:
    May 13, 2007
    Messages:
    901
    The size = the size of the app binary (the file that ends in .app) + the rest of the files in the app bundle compressed with zip.
  3. goodhustle

    goodhustle

    New Member

    Joined:
    Jun 4, 2009
    Messages:
    310
    So the compressed zip should be the final size on the iTunes store? That doesn't seem to be what happened to me - I was at 9.9MB after compressing on my own machine, but on the App Store it shows up as 19.1 MB. I figured that Apple decompresses and then recompresses using a different algorithm, but it was just a guess. Are you saying that your submitted compressed binaries are what's used in the final file size?
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    No...

    Size = (size of app binary) + (rest of files compressed with zip)

    --Eric
  5. junkotron

    junkotron

    New Member

    Joined:
    Feb 22, 2009
    Messages:
    158
    Is there a Unity game out there that's less than 10mb?
  6. goodhustle

    goodhustle

    New Member

    Joined:
    Jun 4, 2009
    Messages:
    310
    Ah, that makes sense. Thanks!
  7. Dreamora

    Dreamora

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    There are a few with Unity iPhone Advanced

    With basic its impossible
  8. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    My Game Marble Challenge is under 10MB.

    Basically you need to have a 4.6MB zip file to get under 10MB
    Apple adds DRM to your app.
    Anything over 4.6MB zip = over 10MB in app store.
  9. spacefrog

    spacefrog

    Member

    Joined:
    Jun 14, 2009
    Messages:
    402
    That's not quite correct. This varies heavily, depending on coding&content in your app. I was able to release an app that was 6.2Mb after i zipped and sent it to apple. After they put their DRM stuff on it, the download size was just 9.7Mb....
  10. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    I know apple has been working to improve their process of DRM.
    I haven't complied an app recently, they may have improved it.
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    Actually no...bliprob, above, already stated the formula for app size.

    --Eric
  12. bliprob

    bliprob

    Member

    Joined:
    May 13, 2007
    Messages:
    901
    Here's an XCode Run Script build phase you can use to automate this:

    Code (csharp):
    1. #!/usr/bin/perl
    2. my $binfile = $ENV{'CODESIGNING_FOLDER_PATH'}.'/'.$ENV{'PRODUCT_NAME'};
    3. my $binSize = -s $binfile;
    4. my $kbsize = $binSize / 1024;
    5. my $mbsize = $kbsize / 1024;
    6.  
    7. print "Binary Size = $mbsize MB ($kbsize KB)\n";
    8.  
    9. $zipResult = `zip -r /tmp/tempAppZip $ENV{'CODESIGNING_FOLDER_PATH'} -x $binfile`;
    10.  
    11. $zipSize = -s "/tmp/tempAppZip.zip";
    12. my $kbsize = $zipSize / 1024;
    13. my $mbsize = $kbsize / 1024;
    14.  
    15. print "Resources size zipped =  $mbsize MB ($kbsize KB)\n";
    16.  
    17. $finalSize = $binSize + $zipSize;
    18. my $kbsize = $finalSize / 1024;
    19. my $mbsize = $kbsize / 1024;
    20.  
    21. print "AppStore size =  $mbsize MB ($kbsize KB)\n";
    22.  
    In XCode:

    1. Right-click on the "Unity-iPhone" target.
    2. Select "Add -> New Build Phase -> New Run Script Build Phase"
    3. Double-click the new "Run Script" item.
    4. Set the shell to "/usr/bin/perl" and copy paste the above text. It should look like this:

    [​IMG]

    5. Build the project, and check the "Build Results" window for the script output.

    For my current project, the results are:

    Oh noes!
  13. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    The zip file you send to apple is all inclusive, the only thing they add is the DRM.

    With Unity the only way to get it under 10MB is with unity Advanced.

    If you build a completely empty unity iphone project with unity iphone basic and xcode the resulting app is 15.1 MB, that is just the size of the engine.

    My game Marble challenge's app is 17.4MB when that file is zipped it is 4.8MB the size of the game on the app store is 9.3MB.
    The downloads on the app store are zip files. Apple adds roughly about 4.5MB of DRM to a unity game.
    My game CRHM is 14.2MB and 4.3MB zipped. App store is 8.8MB
    If you are using iphone advanced you can expect about 4.5MB of DRM added to a game. The DRM has nothing to do with the size of your content, it is just separate code/resources that apple adds before re-zipping the file for resale.

    The app that results in the app store is not an executable, it's a zip file, the iPhone uncompresses it when it gets downloaded.

    The only way to keep the download under 10MB is to keep your zip file under roughly 6MB.
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    This is quite wrong. It's very simple; bliprob already provided a more accurate answer and even made a nice automated way of doing it. Unzip the .ipa file that you download from iTunes and see for yourself. Hint: the actual executable compresses very badly after whatever Apple does to it, but everything else (data, assets, etc.) is the same.

    --Eric
  15. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    The zip file that you upload includes the binary and all the resources.
    That is the complete file there are no other files included.
    The ".app" produced by xcode includes everything.

    There is nothing else to add except DRMat that point
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    Correct.

    The only thing that's touched is the executable, which is re-encoded with DRM. There is no "separate code/resources" added. Why don't you just do what I suggest, unzip your .ipa file, and see for yourself? Continuing to argue about something so easily verifiable isn't doing anyone any favors.

    Since the executable doesn't really compress much anymore after Apple touches it, the final size in the app store depends on the size of the executable to begin with. Everything else is identical and compresses as well as it did before. This is why the formula that bliprob originally provided works.

    --Eric
  17. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    I believe we are saying the same thing, my point was that with unity the executable is always the same size and the apple added drm works out to about 4.5 mb

    the original poster asked about getting a unity game under 10mb on the app store.

    As I said I posted different apps at different sizes and all of them had exactly 4.5MB of drm added, the unity executable doesn't change size no matter what content you inclued unless you have advance to stip out uneccessary components.

    So there is a limit to what you can add to keep the app under 10MB, with a unity executable compiled with advanced with maximum optimization you will always get 4.5mb I'd drm
  18. D22888

    D22888

    New Member

    Joined:
    Apr 18, 2009
    Messages:
    95
    Oh and I did unzip the IPA, there are several added files outside of the .app as well as 3 new files in the .app, but he executable was unchanged...

    Like I said they add files to the .app and then stick that .app into a folder which goes into another folder with some other files they add and then zip the whole thing
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    The executable is not always the same size. It depends on what stripping level you use, and what features you use in your scripts. For example, doing something with System.Text.RegularExpressions will add about 170K to the executable with maximum stripping, and with no stripping it adds 3.7MB. Also it may become larger or smaller in the future depending on what UT does with it.

    Those files don't really add anything to the size, and the executable is not unchanged. Try zipping it, and you'll see:

    [​IMG]

    --Eric
  20. tractiongames

    tractiongames

    New Member

    Joined:
    Jan 26, 2009
    Messages:
    154
    I just tried Bliprod's formula and it gave us a small heart attack. It doesn't seem to be all that accurate from what I can tell but there is every chance we are doing something wrong in the calculation.

    To validate I used an app that we already have on the app store to check.

    I took the package generated by Unity, this was 14.5 meg in size.
    I right clicked and 'show package contents' and copied everything in there into a new folder I created.
    I then moved the .app executable file out of that folder which was (8.9 meg)
    I then zipped what was left in that folder using standard OSX zip. (2 meg)

    According to the formula provided, the size would be 8.9 meg + 2 meg = 10.9 meg, however on the app store its listed as 9.7 meg. Thats nearly an entire Megabyte different.

    So, what did I do wrong?
  21. bliprob

    bliprob

    Member

    Joined:
    May 13, 2007
    Messages:
    901
    tractiongames: not sure what might be wrong there.

    Make sure you're not checking the built size of the Debug configuration, since that typically is larger.

    If you are using Snow Leopard, remember that it now calculates file size with units where 1 MB = 1,000,000 bytes, instead of 1,048,576 bytes. You should do "Get Info" and get the actual number of bytes, rather than relying on the abbreviated value in the Finder window listing. Granted, this would make your app look *bigger* in the Finder, not smaller, but it's worth remembering.

    Also, this method provides a worst-case number. The assumption about the binary size is based on the idea that an encrypted binary can't be compressed at all, but in the real world I'm sure it can be compressed *some*. A better method would be to actually encrypt the binary and then zip it with the resources. I'll look into that.

    My games tend to be so far above the 10 MB line (and anyway I've been convinced by those who say don't worry about the 10 MB barrier) so I made this script mostly as a novelty. But I'd like to make it accurate, so please let me know what you find.
  22. tractiongames

    tractiongames

    New Member

    Joined:
    Jan 26, 2009
    Messages:
    154
    Will do bliprob. FYI - Not using snow leapord.

    I suspect what Eric5h5 just posted a few comments before this one confirms why there is a little bit of a discrepancy. In his Realmaze3D example, a 9.5 binary compressed to 8.2 meg after DRM had been applied. Yes that is far bigger than the 3 meg compressed he got before apple had their wicked way with the file but still represents a 1.3 meg drop in size which would in our case be more than enough to get the filesize under 10 meg.

    Thank you very much for this information as it has already helped us to pick up almost 2 meg in binary size reduction. Be it silly or not, we had our level maps being stored in code (its a tile engine game so we have many large 2D arrays of integers for the level definitions required). After reading how the DRM additions by apple renders the bin file almost un-compressible, we have moved these in-code definitions into text files within the resources folder and the binary file size has dropped 2.5 meg! As you would expect, these text files in the resources folder are compressing very nicely with the .zip processing.

    Still it's going to be very tight going. We have the build size down to 1.6 meg for resources / other files zipped and binary at 8.9 meg totalling 10.5 meg. So if the bin after DRM comes down by as little as 500k we are looking good.

    (Although it would seem it is completely irrelevant, pre-DRM the bin file is dropping from 8.9 meg to 2.8 meg after zip at this end)

    Will let you know once we have submitted what the end result is and thanks again for your help. What would be interesting to find out is how other people's binary files when extracted from the iTunes IPA files are compressing compared to their original sizes. If we could determine a range of compression factors we could greatly improve your prediction formula. (i.e. do most the bin files reduce similar percentage as the Realmaze3D example post DRM or is that ratio quite variable.)
  23. tractiongames

    tractiongames

    New Member

    Joined:
    Jan 26, 2009
    Messages:
    154
    OK, Just grabbed the IPA version of one of our small apps on the App store to see how these theories are stacking up when applied in reverse.

    First point of interest, within the IPA there is a binary called ITunesArtwork which is 104 kb (when compressed it was 100k), im assuming this is the 512x512 resized icon that itunes can display in a non-editable binary format? So right away we have a 100k odd boost in size.

    I then tested the application binary compression:

    Before APPLE / DRM : 8.6 meg -> 2.8 meg
    After APPLE / DRM : 8.6 meg -> 7.3 meg

    The final IPA / ZIP download size from iTunes was 8.9 meg, the .zip file we submitted was 4.2 meg.

    There was a compressed gain of 4.5 meg in the app binary and a compressed gain of 100k in the addition of the ItunesArtwork which pretty much equates to the 4.2 meg we submitted + 4.5 + 0.1 = 8.9 meg download size (allowing for 100k sundries of partial MB in each rounded number used in formula)

    What i find REALLY interesting however is that the compression on the bin file after DRM / iTunes was EXACTLY the same as the Realmaze3D example (even tho the original bin file was 0.9 meg smaller.

    Realmaze3D: 9.5 meg -> 8.2 meg (1.3 meg reduction)
    Our Application: 8.6 meg -> 7.3 meg (1.3 meg reduction)

    Maybe your formula needs to account for a 1.3 meg reduction in the .exe (instead of 0 reduction) as well as adding another 100k for the ItunesArtwork and it will be getting very close to the money shot?

    Definately keen to hear more examples on how the bin file within the IPA compresses to see if this 1.3 meg value is reliable or just a co-incidence.

    EDIT - Just tried one of our larger apps, and yet again the reduction was 1.3 meg

    Before DRM / Itunes: 8.9 meg - > 2.8 meg
    After DRM / Itunes: 8.9 meg -> 7.6 meg - (1.3 meg reduction)
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    Well, 1.6 did change things in this department. With 1.5, the binary for Realmaze3D was 9.5MB, which compressed to 3MB before DRM and 8.2MB after DRM. Now it's 7.4MB, which compresses to 2.7MB before DRM and 7.2MB after DRM (i.e., hardly at all).

    So, with the small amount extra that's added, I think the "Size of binary uncompressed + rest of stuff compressed" rule is quite accurate now.

    --Eric
  25. Randy Edmonds

    Randy Edmonds

    Member

    Joined:
    Oct 10, 2005
    Messages:
    1,115
    Do you guys know that the 10MB limit was recently changed? Now it is a 20MB limit.
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    Yep, I knew that. In my case, once the limit was raised and my game was under it, the effect was exactly zero...sales didn't go up or down any noticeable amount. So as far as I'm concerned this discussion is entirely academic, but still kind of interesting. ;)

    --Eric
  27. RenoRosco

    RenoRosco

    New Member

    Joined:
    Dec 16, 2008
    Messages:
    67
    Like said before the App size is now at 20mb. To archive this you should try to get your zipped app to 10mb. We made the experience that the DRM nearly doubles your App-size. That sucks hard because it takes about 5 minutes to remove the DRM of the app and makes it sensless.

    And it was possible to get an App under 10mb with Unity but you have to plan carefully what and who many textures you can use and how u can compress them. And sounds are also a pain in the ass because the iPhone can play just on mp3.
    We have to remove most of the game sounds to archive the <10mb size for our Memory game we made.
    Even now it is hard if u want good art and sounds in your game and hit the 20mb.
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Messages:
    25,579
    No...as discussed above, it's "size of binary uncompressed, plus rest of stuff compressed".

    It's not that hard, assuming you don't have a massive amount of content. It's easier with Pro, and Unity iPhone 1.6 chopped off 1MB from the distribution size compared to 1.5, so Realmaze3D is now 16.3MB on the store instead of 17.3MB. This has a couple of music tracks, dozens of sound effects, and half a dozen large texture atlases (1024x1024 and 512x512), plus a number of miscellaneous smaller textures.

    --Eric
  29. Randy Edmonds

    Randy Edmonds

    Member

    Joined:
    Oct 10, 2005
    Messages:
    1,115
    Everything I have on the App Store is between 10 and 20 megs. I had tried hard to get them under 10MB but could never do it. Hitting the new 20MB limit won't be too hard.
  30. Dreamora

    Dreamora

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    The DRM impact is pretty easily calculatable:

    Your final size on the store is the size of the application in the package uncompressed + the rest of the app folder compressed
  31. tractiongames

    tractiongames

    New Member

    Joined:
    Jan 26, 2009
    Messages:
    154
    Id just like to add, our game 'Pro Surfing' which weighed in at a hefty 18 meg has gone gangbusters here in Australia since apple lifted the download limit. We instantly shot into 11th in sports (from down near 30) and up to 72nd in Top 100 games, and have maintained these rankings ever since, all purely because our app can now be downloaded over the air. Blew us away!

    Makes me wonder how many people have gone to grab the game in the past and bailed on the idea after realising it required iTunes synch or Wi-fi.

    On the down side, it has also affected our latest project which is about 1 month out from release, we had been battling like maniacs to keep it under 10 meg, and now its all wasted effort. We were super happy with the amount we were achieving with the 10 meg limitation (which is in essence a game of only a couple megs in size on top of the unity base) but now we will have to up the ante on the production value to keep in line with user expectations.

    I think overall, the 20 meg limit will only hurt the little men, ppl who in the past had not even considered looking at big budget titles due to the over-the-air denial and would always go for the little home-brew games are now going to expect more from their OTA downloaded apps.

    Of course for unity developers, its a godsend and opens up the market where before it was practically impossible to get at these OTA downloaders.
  32. Goody!

    Goody!

    New Member

    Joined:
    Sep 11, 2009
    Messages:
    100
    **bump**

    I tried the xcode script but couldn't find the info it was supposed to list? Is it broken?

    I'd be eternally grateful if someone could please elaborate on the specifics of how to determine the size of a pre-submitted app as it will show up as on the app store. My reasons is I'd like to stay under the 20meg 3G limit, if possible, and I need to know how much space to allow for art and SFX.

    Thanks!
  33. j.robichaud

    j.robichaud

    Member

    Joined:
    Aug 26, 2010
    Messages:
    31
    I made a perl script i'd like to share.

    It is used this way:
    theScript.pl --execname=MyAppExecName /SomePath/*.app

    It will print the file names with their respective file sizes in bytes and also in MB.

    Code (csharp):
    1. #!/usr/bin/perl
    2. use strict;
    3. use File::stat;
    4. use Getopt::Long;
    5.  
    6. sub CalculateBuildSize
    7. {  
    8.     my $executableName = $_[1];
    9.     my $app = $_[0];
    10.    
    11.     my $appCP = "Tmp.app";
    12.     print `cp -R $app/ $appCP`;
    13.     print `mv $appCP/$executableName TmpExec`;
    14.     #print `ditto -ck --sequesterRsrc --keepParent $appCP $appCP.zip`; #Alternate compression method, compress slightly more than zip
    15.     `zip -r $appCP.zip $appCP`;
    16.     my $execsize = stat("TmpExec")->size; #A
    17.     my $archiveSize = stat($appCP.".zip")->size; #B
    18.     my $drmSize = 100*1024; #C
    19.    
    20.     print `rm $appCP.zip`;
    21.     print `rm TmpExec`;
    22.     print `rm -r $appCP`;
    23.    
    24.     my $totalSize = $execsize + $archiveSize + $drmSize; #A + B + C = maximum size of your App after approval
    25.     my $totalSizeMb = sprintf("%.2f", $totalSize/1024/1024);
    26.    
    27.     print $app . ": ". $totalSize . " bytes (" . $totalSizeMb ." MB)\n"
    28. }
    29.  
    30. my $execname ="";
    31. my $result = GetOptions ("execname=s" => \$execname);  
    32.  
    33. if ( $execname )
    34. {
    35.     foreach (@ARGV) {
    36.         CalculateBuildSize($_,$execname);
    37.     }
    38. }
    39. else
    40. {
    41.     print "Executable name was not specified, please use --execname=MyAppExecName\n";
    42. }

    Source: http://answers.unity3d.com/questions/14952/steps-to-determine-iphone-app-size-please

    I am wondering if anyone got an application with a file size higher than this calculated maximum size in the app store. Ever heard about such a situation?
  34. markofjohnson

    markofjohnson

    Member

    Joined:
    Oct 12, 2010
    Messages:
    67
    Our 16mb ipa file ended up being a 35mb download :-(.
    Can someone tell me how much download size we can hope to save with a Unity Pro iOS license? Of course I guess it depends, but does anyone have some data points they can share?