Mobile Development 16 min read

How Baidu Cut Its iOS App Size by 50 MB: A Deep Dive into Package Optimization

This article examines why Baidu's super‑app needed a drastic reduction in its iOS package size, outlines the metrics that link bundle size to download conversion, compares the app‑size footprints of major domestic and overseas apps, and details the multi‑layered technical solutions—resource trimming, architecture safeguards, compiler tweaks, image compression, and code slimming—that together saved over 50 MB while preserving functionality.

Baidu App Technology
Baidu App Technology
Baidu App Technology
How Baidu Cut Its iOS App Size by 50 MB: A Deep Dive into Package Optimization

1. Introduction

Baidu APP, a national‑level super‑app with daily active users exceeding 100 million, has grown from a simple search tool to a massive platform that includes feed, video, live streaming, novels, shopping, mini‑programs, cloud storage and many vertical modules. Its binary size ballooned from a few dozen megabytes to a peak of 420 MB, with each release typically adding at least 3 MB, causing noticeable download‑conversion and uninstall‑rate penalties.

2. Background and Motivation

Google Play data shows that every 6 MB increase in package size reduces download conversion by roughly 1 %. Conversely, shrinking the APK by 10 MB can boost global conversion by about 1.75 %. iOS App Store does not publish download‑size metrics, but the same principle applies: a smaller bundle improves user acquisition and reduces storage pressure on low‑capacity devices.

When the package exceeds 200 MB, iOS imposes two constraints: (1) devices running iOS 13‑ or lower cannot download the app over cellular, and (2) iOS 13+ users must manually enable cellular download. Large bundles also increase pre‑main execution time, raise the probability of SIGKILL during launch, and make the codebase harder to maintain.

3. iOS Package Generation Process

After uploading an IPA to App Store Connect, Apple’s App Thinning creates device‑specific slices. Users download only the assets matching their hardware, which reduces the final installation size compared to the original IPA.

4. Composition of an iOS Package

The IPA consists of several key parts:

Mach‑O file : the executable binary.

Watch app : optional watchOS companion.

Widget components : home‑screen widgets that launch the main app.

Custom dynamic libraries : code loaded at runtime; removing unused libraries can save tens of megabytes.

Swift system libraries : bundled only on iOS versions prior to Swift ABI stability.

Assets.car : compiled image assets from Asset Catalog.

Bundle images : raw image resources placed directly in the bundle.

Other bundles and configuration files : plist, js, css, json, model files, etc.

5. Industry‑wide App Size Analysis

A snapshot of September‑2022 App Store packages for major Chinese and foreign apps reveals three size tiers:

First tier (≈ 500 MB): QQ, WeChat.

Second tier (≈ 380 MB): Baidu, TikTok.

Third tier (≈ 320 MB): Kuaishou.

Smaller domestic apps (≈ 250 MB): Meituan, Taobao, Jinri Toutiao.

Foreign apps (≈ 280 MB): Facebook, YouTube. Key observations:

Foreign apps rely heavily on dynamic libraries (e.g., Facebook uses 53 custom dylibs, keeping the main Mach‑O under 9 MB).

Most Chinese apps ship only 5‑6 custom dylibs.

Swift adoption is widespread abroad; domestically, only Meituan lacks Swift libraries.

Asset Catalog is the dominant image delivery mechanism; Baidu’s bundle images are several times larger than competitors, indicating significant redundancy.

6. Technical Solution Overview

The optimization effort is divided into four major tracks:

Resource optimization : trim unused images, convert PNG/JPEG to HEIC, compress large assets with WebP or TinyPNG, and remove duplicate or oversized resources.

Architecture safeguards : implement a volume‑monitoring pipeline using LinkMap and Mach‑O analysis, enforce quota and gate‑keeping policies to prevent uncontrolled growth.

Compiler optimizations : enable size‑focused flags for Objective‑C/C++, Swift (whole‑module compilation, -Osize), thin LTO, strip debug symbols, dead‑code stripping, and Asset Catalog space optimization.

GCC_OPTIMIZATION_LEVEL = z
SWIFT_COMPILATION_MODE = wholemodule
SWIFT_OPTIMIZATION_LEVEL = -Osize
LLVM_LTO = YES_THIN
COPY_PHASE_STRIP = YES
GCC_SYMBOLS_PRIVATE_EXTERN = YES_THIN
DEPLOYMENT_POSTPROCESSING = YES
STRIP_INSTALLED_PRODUCT = YES
DEAD_CODE_STRIPPING = YES
ASSETCATALOG_COMPILER_OPTIMIZATION = space

Image pipeline : replace legacy bundle‑based 2×/3× images with Asset Catalog slices, migrate to HEIC (≈ 50 % size reduction vs PNG), fall back to WebP for alpha‑channel PNGs, and use TinyPNG for assets < 100 KB to avoid CPU‑heavy decoding.

7. Optimization Benefits

From July to December 2022, Baidu APP reduced its IPA from 395 MB to 352 MB—a 50 MB saving (≈ 12.6 %). Compared with peers, Baidu moved from the second tier to a more competitive size range. The breakdown of ROI (largest to smallest) is:

Engineering/architecture improvements.

Compiler‑level size reductions.

Image compression.

Resource file trimming.

Code slimming.

Additional gains include a 30 % download‑size reduction reported by Xcode 14’s new compiler, which translated to a 26 MB saving (≈ 6.5 %) for Baidu APP.

8. Conclusion

The article presented the necessity of iOS package size reduction, clarified the distinction between download and installation metrics, dissected the IPA composition, benchmarked major apps, and detailed Baidu APP’s multi‑pronged optimization strategy. Future posts will dive deeper into each technique’s implementation details.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mobile developmentiOSresource managementCompiler Optimizationapp size optimization
Baidu App Technology
Written by

Baidu App Technology

Official Baidu App Tech Account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.