70% reduction in iOS app footprint of “Flipping Blocks” Unity game


We achieved a reduction of 59% on the download and 70% on the footprint sizes for the Unity app “Flipping Blocks” on the iOS platform.

Most of the gain came from moving graphic assets out of the build to asset bundles that are downloaded as needed at runtime.

A small additional gain was achieved by enabling Bitcode.

All numbers in MB.

Measure Footprint Before Footprint After Footprint saving Download Before Download After Download saving
Enable Bitcode 385.0 371.0 14.0 83.6 79.2 4.4
Asset Bundling the graphics 371.0 117.0 254.0 79.2 34.0 45.2
TOTALS 385.0 117.0 268.0 83.6 34.0 49.6


By far the biggest problem for the footprint (the amount of space the app takes up in the iPhone’s storage) is the graphics files.
The PNG files get expanded to their full size (about 20 time bigger than compressed). On Android it seems the graphics assets are expanded for use when the app is actually activated, whereas on iOS the app is completely unpacked on installation and takes up an inordinate amount of room on your disk. At least this is the story our phones are telling us.
flippingblocks-android-sizes_2016-05-12-11-04-48 Size of Flipping Blocks 1.3 on iPhone 352+26MB
You can see how big the graphics files are by checking the build log after making  a build. On OS X you will find the build log under ~/Library/Logs/Unity/Editor.log.  Look for “Textures” or “Complete size”.  This is what I currently see in my log (I’ve already done some optimization so textures now take “only” 92% of the space compared to the previous 97%):
Textures      82.2 mb    92.0%
Meshes        43.9 kb    0.0%
Animations    6.1 kb     0.0%
Sounds        54.8 kb    0.1%
Shaders       10.0 kb    0.0%
Other Assets  1.0 mb     1.2%
Levels        464.3 kb   0.5%
Scripts       1.2 mb     1.3%
Included DLLs 4.1 mb     4.6%
File headers  272.7 kb   0.3%
Complete size 89.3 mb    100.0%

Used Assets and files from the Resources folder, sorted by uncompressed size:
 4.0 mb  4.5% Assets/Fonts/fontawesome-webfont.ttf
 2.7 mb  3.0% Assets/Resources/welcome-bg.png
 2.7 mb  3.0% Assets/Resources/dialog-frame.png
 1.9 mb  2.1% Assets/Resources/tip-screen-2.png
 1.9 mb  2.1% Assets/Resources/tip-screen-3.png
 1.9 mb  2.1% Assets/Resources/tip-screen-1.png
 1.7 mb  1.9% Assets/Resources/tetrominos.png
 1.4 mb  1.6% Assets/Resources/tip-frame.png
 1.4 mb  1.6% Assets/Resources/medals/score medal bronze.png
 1.4 mb  1.6% Assets/Resources/medals/score medal silver.png
 1.4 mb  1.6% Assets/Resources/medals/score medal gold.png
 1.4 mb  1.5% Assets/Graphics/help/explanation-help.png
 936.2 kb        1.0% Assets/Resources/language/en/buttons/forgotten-password-en.png
 936.2 kb        1.0% Assets/Resources/language/en/buttons/forgotten-password-en-p.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/next-game-en.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/ok-en-p.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/tutorial-en-p.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/cancel-en-p.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/next-game-en-p.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/ok-en.png
 936.1 kb        1.0% Assets/Resources/language/en/buttons/tutorial-en.png

Those look very big. The actual file sizes are much smaller, typically by a factor of 10 to 20 (sizes in 5th column of the following ls output):

-rw-r--r--  1 pete  staff  13578  6 May 22:15 Assets/Resources/welcome-bg.png
-rw-r--r--  1 pete  staff  13545  6 May 22:15 Assets/Resources/dialog-frame.png
-rw-r--r--  1 pete  staff  19325  6 May 22:15 Assets/Resources/tip-screen-2.png
-rw-r--r--  1 pete  staff  29888  6 May 22:15 Assets/Resources/tip-screen-3.png
-rw-r--r--  1 pete  staff  22059  6 May 22:15 Assets/Resources/tip-screen-1.png
-rw-r--r--  1 pete  staff  13477  6 May 22:15 Assets/Resources/tetrominos.png
-rw-r--r--  1 pete  staff  11989  6 May 22:15 Assets/Resources/tip-frame.png
-rw-r--r--  1 pete  staff  85352  6 May 22:15 Assets/Resources/medals/score medal bronze.png
-rw-r--r--  1 pete  staff  80349  6 May 22:15 Assets/Resources/medals/score medal silver.png
-rw-r--r--  1 pete  staff  84754  6 May 22:15 Assets/Resources/medals/score medal gold.png
-rw-r--r--  1 pete  staff  50619  6 May 22:15 Assets/Resources/language/en/buttons/forgotten-password-en.png
-rw-r--r--  1 pete  staff  52430  6 May 22:15 Assets/Resources/language/en/buttons/forgotten-password-en-p.png
-rw-r--r--  1 pete  staff  43879  6 May 22:15 Assets/Resources/language/en/buttons/next-game-en.png
-rw-r--r--  1 pete  staff  39526  6 May 22:15 Assets/Resources/language/en/buttons/ok-en-p.png
-rw-r--r--  1 pete  staff  40831  6 May 22:15 Assets/Resources/language/en/buttons/tutorial-en-p.png
-rw-r--r--  1 pete  staff  47879  6 May 22:15 Assets/Resources/language/en/buttons/cancel-en-p.png
-rw-r--r--  1 pete  staff  41438  6 May 22:15 Assets/Resources/language/en/buttons/next-game-en-p.png
-rw-r--r--  1 pete  staff  41108  6 May 22:15 Assets/Resources/language/en/buttons/ok-en.png
-rw-r--r--  1 pete  staff  42791  6 May 22:15 Assets/Resources/language/en/buttons/tutorial-en.png

If you want to see for yourself where your app is using up space, unpack your IPA file

$ unzip Unity-iPhone.ipa

You will find giant files called resources.assets and resources.assets.resS in the directory Payload/yourappname.app/Data/.  I believe that the resS file is created from files that are assigned to asset bundles. All of the graphic assets used by your app are in these files, in fully expanded, uncompressed form. The reasoning is probably that concatenating the contents of multiple files and compressing the result gets you a better compression result than compressing the files individually.

Asset Bundles

I assigned our language specific graphics to asset bundles. Asset bundles have to built separately for each platform. You cannot use Android asset bundles with iOS.  The asset bundles are kept on a web server and downloaded as needed by the app.  Logic has to be written to handle this, especially if your code depends on Resources.Load. More about this in my previous post dealing with asset bundles for the Android version of the game.

You have to prevent any files that have been assigned to asset bundles getting into the build.  My Android trick of making the asset bundled files unreadable by removing their read permissions didn’t work. This just causes Unity to hang. You have to move the files out of their Resources directory to a place where the build cannot find them. I did this by creating a temporary directory called “language_tmp” next to my Assets directory and moving the language files there before starting the build.

$ mkdir -p language_tmp
$ mv Assets/Resources/language/{de,es,fr,it,ja,zh} language_tmp/

Once those files are out of the way the resources.assets and resources.assets.resS are much smaller.

The reason for these tricks is that Unity automatically puts everything from Resources folders into the build, no questions asked. For historical reasons all my graphics files are in Resources folders. If you can avoid doing this, do so.

The download size of the app was reduced by this measure from 79.2 MB to 34 MB.  The footprint went from 371 MB to 117 MB, a massive reduction of 254 MB!


We also got a small win by enabling Bitcode in Xcode. This makes it possible for Apple to build device specific downloads of your app. This reduced the footprint by about 14MB and the download size by 4.4MB. Enabling bitcode will make a big proportional difference if your app is not graphics heavy. Every little bit helps.

There is still room for improvement. I have kept the English language assets in the IPA because then at least something pretty is available should you go offline immediately after download. It might be worth asset bundling those too. Most of our buttons are graphic rather than text because we were not able to achieve our curvy font effects in uGUI with conventional means. If anybody knows how to get those effects using text only then please let me know!


Previous post on Android size reduction

iOS game size on the store

Reducing the File Size of the Build


Posted by Tuesday May 24th, 2016

Leave a Reply

No Comments

appMotivate offers:

  • Consulting
  • Specification
  • Project Management
  • Programming

Last blog article