At Get Wrecked, we spent the entire day working op optimizations today. I always feel like I want to write about it, but usually I’m on a tight deadline and can’t make the time. Today, this wasn’t the case, so here it is!

The 100MB download limit in iOS is tough to get around. In the ever-growing community of frameworks and features, keeping it under that 100MB is really hard. Asset bundles are not ideal for all games, because a lot of users are unable to sit and wait for multiple MBs to download before your app or level starts. At Get Wrecked we have a particularly interesting case. Our goal is to package an entire 3D unity game into less than 100MB, with assets looking somewhat like this, and libraries such as Facebook, Everyplay, Twitter, and more included.

img_2772

The real key to getting the builds to a size you need, at a performance that you are comfortable with, is simply testing, testing, and more testing. You are simply going to need to have patience, try different settings, upload different things to iTunes connect, and see what works best for you. Here are a few things that can help you out:

  1. Ensure that you have reached the maximum level of iOS stripping, for more info on iOS stripping, see this post.
  2. Enabling bitcode DOES increase the size of your over-the-air download. In our case, it was the difference between 130 and 70MB. If you wish to turn bitcode off, you can do so in your xcode project, or using a post build attribute such as this one.
  3. The Launch image in your xcode project is NOT optimized. While running something through a compression algorithm doesn’t work because Unity decompresses and stores images without much compression in order to decrease startup time, it does work for the launch images that are generated by Untiy after project generation. To be exact, this is {build}/LaunchScreen-*.png and {build}/Unity-iPhone/Images.xcassets/*.png, run all your images through a lossless compression algorithm such as tinypng.com in order to save a few MBs (10 in our case).
  4. If this isn’t enough, it’s time to start looking at your asset logs. Run your build in Unity and open the Editor log, it’s this ridiculously small icon next to your console preferences. Screen Shot 2016-11-02 at 7.35.46 PM.pngNow search for this:screen-shot-2016-11-02-at-7-36-35-pmIn your case, the assets are likely not as optimized. In our case, they are already optimized. With a 111MB in uncompressed assets, we were able to achieve an over-the-air size of 70MB. Go over each asset and change the resolution to the lowest possible quality that your users won’t notice. The best compression setting is PVRTC for iOS. While you are at it, check out Resource Checker in order to see large textures in-memory. Reducing the resolution on these will also decrease build size, as well as memory consumption. Also, please use sprite atlases – you will see the wonders this does!
  5. Check for unused libraries in your project, or libraries that are using far too much space for their functionality. Commands such as df and ls -lh might come in useful here, run these in your project files and see which files really stand out and need to be reduced in size. Keep in mind that these individual libraries do not necessarily have the same build effect as your textures – generally, these are compiled for multiple architectures, and if a library is 20MB, it generally only affects your build size by about 6MB, due to the fact that libraries often include architecture support for i386, arm64, and arm7 in the same library
  6. Check that the /Plugins/Android is not included in your iOS project. See this post for more information.
  7. Make sure you don’t have any unused scenes in your build settings
  8. screen-shot-2016-11-02-at-8-00-05-pm
  9. Build your project, and check out the archive before you submit it to iTunes Connect. You can do so by clicking “Product -> Archive”, letting it archive, and when it’s done, “Window -> Organizer” to pop up this interface and find the build location.Screen Shot 2016-11-02 at 8.00.41 PM.pngscreen-shot-2016-11-02-at-7-54-14-pmscreen-shot-2016-11-02-at-7-54-48-pm

    Under “Products/Applications/game.app” Run the mv command to turn your .app into a browsable directory screen-shot-2016-11-02-at-7-55-52-pmIn this directory you’ll be able to see a lot of the stuff we did, and also find inspiration for more things you can do. screen-shot-2016-11-02-at-7-55-59-pm

Now, there are a lot more things that could result in a bigger than expected build size, and I’m sure there are a lot more things you can to do get below it also.

If you’d like to add to this list, or have further questions (I’m usually happy to answer questions), leave a comment below with your specific use case, and I’ll try to help!

All the best,

Pim