How to Optimize & Automate Mobile App Size? Unified, Automated Monitoring.

Vijaykumar Patil
Intuit Engineering
Published in
6 min readMay 31, 2023

This blog is co-authored by Vijaykumar Patil, Senior Software Engineer, Yogesh Khandelwal, Staff Software Engineer, and Laks S, Engineering Manager, at Intuit.

Everyone knows that optimizing for size is a critical factor in a mobile app’s success:

  • Faster download times.
  • Reduced storage space requirements.
  • Increased user engagement.
  • Improved performance on devices with limited resources.
  • Higher installation rates. (According to Google, every 6MB increase in app size reduces the installation rate by 1%.)

To deliver awesome mobile experiences for our customers, Intuit has built a robust, unified, and automated method for app size monitoring and recommendations. Our mobile applications — including TurboTax, QuickBooks, Mint, Credit Karma, and Mailchimp — serve more than 100 million customers around the world.

Here’s how we prevent bloated apps from getting into the release process.

Monitor app size from the beginning of the dev process

It’s critical to assess app size throughout the development process. And it’s never too early to start. Modern apps rely on a plethora of in-house and third-party libraries. As a result, app size can quickly become unmanageable, especially if a large team is handling multiple modules.

Automating size monitoring at this stage will significantly improve development velocity and make it much easier to optimize size. Intuit uses an app thinning process for iOS and APK Analyzer for Android. For this blog, we’ll focus on our approach to iOS.

iOS offers a manual process that leverages Xcode’s built-in reporting tools. However, this approach does not monitor app size at regular intervals. That’s why we use a command line interface (CLI) utility in our continuous integration (CI) workflow, which automates an app size report in build scripts or continuous integration workflows, using the command below. This seamless integration functions in auto-pilot mode, producing centralized app-size reports.

xcodebuild -exportArchive -archivePath iOSApp.xcarchive -exportPath Release/MyApp -exportOptionsPlist OptionsPlist.plist

If you adopt the CLI utility, remember to:

  • Replace all file names and paths as necessary.
  • Provide xcodebuild with an export options property list.
  • Include the thinning key, with <thin-for-all-variants> as the value.

Integrate size monitoring throughout the dev cycle

App size checks must be continuously integrated into the critically important CI build phase to ensure app size remains within acceptable limits throughout the development process.

In our CI pipeline, app size information is automatically generated for every pull request (PR) and shared as a PR comment. The system displays a red dot if the app has increased in size compared to the previous release, and a green dot if there is no change in size.

This approach allows the development team to quickly identify possible causes for increased app size. If the app size exceeds the acceptable threshold, the team can reduce its size before merging the pull request, ensuring that the app remains optimized for performance.

The automated system simultaneously sends the same information in a Slack notification to the entire team, so they can apply their collective knowledge to quickly find a fix.

Automatically identify files that are too large

With the information provided in an app size report, it’s now possible to evaluate the app’s composition at a granular level. Within Intuit’s development portal, a developer will find comprehensive information about each app, including app size insights. This feature allows them to easily identify the specific libraries or files that are contributing to app size, and to collaborate with the respective teams to optimize them accordingly.

A six-step approach for reducing app size

Once you’ve identified the underlying issues related to app size, the true benefits come from leveraging some of the numerous open-source libraries that can be deployed in CI workflows. This process empowers developers to take meaningful actions quickly, improving overall development velocity. We approach app size optimization via the following steps:

1. Eliminate unused code. In addition to helping reduce app size, eliminating unused code improves code quality and maintainability. We’ve found two tools to be particularly helpful:

  • Periphery combines static and index-based analysis to provide more accurate recommendations. The command line option makes it very easy to integrate with the build pipeline.
  • PMD is an open-source library that can detect code duplication and can be customized with user-defined rules. It provides reports on the number and location of duplicated code fragments.

2. Remove unused images and compress media files. FengNiao is an open-source command line tool that lists unused images and their size. It also has options to list, delete, or ignore the images. CLI makes it simple to integrate this tool with the build pipeline. ImageOptim is an open-source tool that compresses and optimizes images using various algorithms, making them as small as possible while retaining their original quality. We’ve integrated this CLI option into the build pipeline. Meanwhile, audio files in the app bundle can be optimized with the LAME library to reduce size.

3. Minify localized strings. Minifying localized strings can reduce the amount of data that needs to be loaded into memory, improving the app’s performance and reducing its overall size. NSLocalizer can extract and minify localized strings in the Xcode project.

4. Employ Asset Catalog. The Asset Catalog feature in Xcode provides a convenient way to organize and manage app resources, enabling developers to use a single image asset for multiple resolutions, thereby reducing the number of images that need to be loaded into memory.

5. Strip binary symbols. Binary symbols are symbolic information (such as function names, variable names, and line numbers) that are included in an app’s compiled binary. While they are useful for debugging and analysis, they are not needed at runtime. Stripping off binary symbols can help reduce the size of iOS apps and improve their performance. While the size reduction is typically small, it is still a worthwhile optimization, especially for larger and more complex apps.

6. Manage files. When an iOS app is launched, it must load all of its resources into memory. By reducing the number of files in an app, you can reduce its loading time and its disk space usage, which can improve its performance and free up valuable storage space on a user’s device. We recommend the following:

  • Remove duplicate files. Files having the same “checksum” are duplicates that can be removed from the app’s bundle. The library rmlint lists duplicate and empty files, along with file size information, in a JSON (Javascript Object Notation) text-based format.
  • Minimize file overhead. Every file in an iOS app has overhead, such as file headers, metadata, and other information required to store and manage the file. By reducing the number of files in an app, you can reduce both overhead and overall app size.

Reducing app bloat = optimal user experiences

With every megabyte of app size reduction, users experience faster download and installation times, better battery life, and increased storage space. Effective monitoring and optimization of mobile app size are essential to successful app development. By thoroughly understanding key contributors to app size, you can ensure that the app remains within an acceptable size range to deliver fast, efficient, and user-friendly experiences.

Many thanks to the team!

We’d like to thank Shyam Vasudevan, Pallavi Lohkare, Rajeev Kumar, Omer Muhammed, and Ashwani Kumar Sharma for their invaluable contributions.

--

--