Here is how I reduced the size of my game on the App Store from 570MB to 82MB

I posted this on reddit but thought I’d also post this here to spread the knowledge!

 

I managed to reduce the size of my game on the App Store from 570MB to 82MB, on Google Play the game is 48MB, but this is out of the box with default settings (and apparently because Android uses its own compression).

 

Settings to change

When I created a MonoGame project a lot of configurations came with default settings, here is what I changed to reduce the size:

  • Enable content compression. This saved me 400MB at least. By default this is off because we don’t know what platform you’re building the game for. If you’re building for Android this should be off as Android has their own compression (official docs, forum post)
    • Enable this by setting /compress:True in your .mgcb file
       
  • Only target one architecture. This saved me a dozen of MB. I only target ARM64 and not ARMv7, ARMv7s as they are for older devices link1, link2 (most of which I would assume is not owned by my target audience). You will also need to increase your MinimumOSVersion to at least 9 in your info.plist file
    • This is done changing your .csproj file, change line <MtouchArch>ARMv7, ARMv7s, ARM64</MtouchArch> to <MtouchArch>ARM64</MtouchArch>. Do this everywhere (especially for the “Release|iPhone” PropertyGroup)
    • Alternatively you can change this setting via your IDE. In Rider IDE, it is under Project’s Properties → Release | iPhone → Architecture → Dropdown → Choose ARM64
       
  • Link behaviour to Link Everything. This didn’t save much, but my game does not use a lot of libraries. Here are useful links on this link1, link2, link3, link4. A safer setting can also be Link SDK assemblies only. By default my setting was Don’t link which should not be set for iOS
    • Enable this by changing your .csproj file, add line <MtouchLink>Full</MtouchLink>. Do this for the “Release|iPhone” PropertyGroup
    • Alternatively you can change this setting via your IDE. In Rider IDE, it is under Project’s Properties → Release | iPhone → Link behavior → Dropdown → Choose Link Everything

 

With everything above in place if I build my game now the app size will be 126MB

 

How to build/publish

This next bit is weird and I don’t fully understand why I have to build the project twice but this also significantly reduced the app size (from 126MB to 82MB).

  1. First step suggested by everyone is to clean the whole solution. This includes deleting all bin and obj folders for a clean slate. Run the below deletion command from your solution root folder from a terminal.
    • find . -iname "bin" | xargs rm -rf; find . -iname "obj" | xargs rm -rf
  2. Restore Nuget
  3. Ensure you’ve set your build configuration to Release | iPhone and not Debug, and you’ve updated your Signing + Provision Profile to distribution.
  4. Right Click Project → Archive for Publish
    • By now my .xcarchive is 126MB (which is roughly what size will appear on the App Store)
  5. Right Click Project → Archive for Publish again
    • By now my .xcarchive is still 126MB (as expected)
  6. Change info.plist's MinimumOSVersion to 11
  7. Right Click Project → Archive for Publish
    • By now my .xcarchive is 82MB, but I can’t upload this build to the App Store as it will complain about the OSVersion incompatibility
  8. Change info.plist's MinimumOSVersion back to 9
  9. Right Click Project → Archive for Publish
    • By now my .xcarchive is 82MB, I can sign and publish this archive and it will be accepted by the App Store

 

Following the steps above if I build my game now the app size will be 82MB. Very similar to the Android version 48MB which comes out of the box.

 

If there are any further suggestions anyone has to reduce a game’s app size, please comment below!

 

More references: link1, link2. I hope this helps!

1 Like