Reduce App Size

i.vikash
6 min readNov 14, 2021

--

How to optimize iOS app size

In this post we will try to understand how we can reduce the size of an iOS app. But before that let’s answer one question-

Why it is important ?

There are multiple reasons for this, let’s discuss few of them-

  1. Storage : Now a days users carry a lot of contents in phone and the storage is limited. So users have to uninstall the apps which are consuming a lot of memory.
  2. Network Connection : If users download app in mobile network, their download speed and data plan may be limited. So it may take much time to download the app or result to additional data cost.
  3. App Store Limit : In mobile network, App Store limits the size of the apps user can download. So if user has no wifi then your app can lose those users.

Looking to these issues it will be a good idea to keep our app below the size limit to maximize the app installations and minimize the installation time.

So Let’s Start:

Before we start optimizing let’s understand how we measure the app size?

Measure app download and installation sizes:

App size cann’t be measured from the app bundle, XCARCHIVE bundle or IPA file because these binaries contains other resources and files which will not get downloaded when user download from App Store.

We can measure the app size at different stages-

1. During Development:

By creating size report

Archive from Xcode> Export your archived app (Choose “All compatible device variants” for app thinning, and enable Rebuild from Bitcode during export)

Once export process gets completed, below folder gets created-

Here the “App Thinning Size Report.txt” file contains compressed and uncompressed sizes information for all variant.

Sample from app size report

2. From App Store or TestFlight app:

By downloading “App Store File Sizes

Follow : https://help.apple.com/app-store-connect/#/dev3b56ce97c

https://help.apple.com/app-store-connect/#/dev3b56ce97c
https://help.apple.com/app-store-connect/#/dev3b56ce97c

Till now we have measured the App Size, now it’s time to check and optimize the app size if possible.

We can divide optimization into levels-

  1. Basic Optimization
  2. Advanced Optimization

Let’s understand one by one.

Basic Optimization

It will help us to quickly review and reduce app size.

Check Build Settings :

1st step is to check your target’s build settings, and make sure you’re using “Fastest, Smallest [-Os]” optimization level.

Identify and Remove Unused Assets:

Create an IPA file identify unnecessary files and unused assets like image, videos, audios, headers etc and remove it from project or targets.

Archive from Xcode> Export archived app > Navigate to the IPA file > Change the extension of the IPA file to ZIP > UnZIP

IPA files with one Zip and one UnZip state

Now open Payload > Show Package Contents. Here we can check the size of contents, and then optimize it.

Use file Assets For Data:

If we want to ship some data in app, consider using asset files instead of putting the data into source code. For example if we want to use some mock data in app use property list instead of using strings in code. It allows App Store Connect to more efficiently compress the app.

Adopt Asset Catalogs:

Use asset catalogs ( For images, textures, data etc) instead of putting in app bundle directly. It allows Xcode and App Store to optimize app’s assets. It significantly reduces the size of the app .

Checkout this for more details :

https://help.apple.com/xcode/mac/current/index.html?localePath=en.lproj#/dev10510b1f7

Enable bitcode:

Bitcode is an Apple technology that enables you to recompile your app to reduce its size. The recompilation happens when you upload your app to App Store Connect or export it for Ad Hoc, Development, or Enterprise distribution.

Checkout this for more details : https://help.apple.com/xcode/mac/11.0/index.html?localePath=en.lproj#/devde46df08a

Advanced Optimization

Till now we have seen how basic optimization decreases the app size. We can further optimize app size to provide a fast download, installation, and update experience.

Optimize asset files:

If we check the size of contents in app, assets are those who takes larger portion of app size. So optimizetion of assets (like image,video and audio) will help us to reduce the size significantly.

The major type of content on which we can target first-

Image : Since images are the most used assets in all the apps. So using a more efficient image file format is a good way to reduce app’s size. Like HEIF format. If app uses PNG files, consider using 8-bit instead of 32-bit PNGs.

Video: Use efficient video format with HEVC format.

Audio: Use compressed audio with ACC or MP3 codecs, also try to use reduced bit rate.

Reduce the Size of App Updates:

App update is an important part of app lifecycle and due to daily changes in iOS and devices some apps need frequent updates. So it is also an important point to consider.

App Store creates an update package when an update is available on store. During download it will only download the updated package not the whole app.

App Store compares one or more prior versions of your app to the new version and creates an optimized package. This package contains only the content that has changed between versions of your app, excluding any content that didn’t change. This comparison looks at everything in the application bundle, including the application executable, storyboards, nibs, localizations, and other assets, like images.

So the main point here is if these things are taken care by App Store only, then as a developer why should we worried about it ?

The answer is- as a developer we can take care of some points to mimimize the update package.

We can consider the below points-

  • Don’t make unnecessary modifications to files. Compare the contents of the prior and new versions of your app with diff or another directory comparison tool, and verify that it doesn’t contain any unexpected changes.
  • Store content that you expect to change in an update in separate files from content that you don’t expect to change.

Adopt On-Demand Resources:

Analyze all of your app’s assets and determine which resources it uses infrequently. Group the infrequently used resources into asset packs. When you upload your app to App Store Connect, asset packs don’t become part of your app’s initial download or app updates. Instead, the app can download them separately as needed.

Checkout for more details:

App Thinning:

If app thinning is enabled the app’s IPA file only contains resources and code that’s necessary to run the app on a particular device. App Store and TestFlight build already leverage app thinning.

So the question is why we are discussing this?

Answer is- sometime we distribute our app as an in-house enterprise app, or distribute builds to testers without using TestFlight, then app thinning will help us to reduce app size.

Conclusion :

In this post we have seen that by adjusting the project settings, using technologies like bitcode and assets catalogs we can reduce our app size significantly.

So if you’re starting a new app project, try to adopt these technologies in your app’s development life cycle. It will help us to do the optimizations in later stages.

Thank you for reading!

--

--

i.vikash

Tech enthusiast exploring software architecture, development, and innovation. Join me on my journey of tech discovery! 🚀 #TechExploration