Mobile Development 31 min read

Comprehensive Guide to iOS App Package Size Optimization

This article systematically explains how to analyze, reduce, and monitor iOS IPA package size by examining Xcode build settings, resource files, and code, providing detailed step‑by‑step configurations, tables of component sizes, practical scripts, and best‑practice recommendations for sustainable bundle‑size management.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Comprehensive Guide to iOS App Package Size Optimization

Background

Package size optimization is an inevitable part of iOS project development. Existing articles offer fragmented advice, so the author consolidates knowledge, explains the rationale behind each optimization, and presents a logical workflow to understand both the "how" and the "why" of size reduction.

Analysis

Before slimming a package, identify the factors influencing its size: Xcode build settings, resources, and code. The author recommends a three‑step process—analysis, factor categorization (controllable vs. non‑controllable), and execution—often visualized with a mind‑map.

IPA Package Composition

An IPA is essentially a zip file. After renaming to .zip and extracting, the Payload folder contains the *.app bundle, which includes the following components (sizes from the author’s initial build):

Content

Size

_CodeSignature

93 KB

.lproj

4 KB

Frameworks

37.5 MB

Plugins

181 KB

Assets.car

4.9 MB

embedded.mobileprovision

8 KB

Info.plist

6 KB

Executable (xxx)

13 MB

Other resources

1.4 MB

Xcode Build‑Setting Optimizations

The author lists concrete Xcode settings that shrink the binary:

Disable C++ and Objective‑C exceptions (Enable C++ Exceptions = NO, Enable Objective‑C Exceptions = NO, add -fno-exceptions to Other C Flags).

Set Architectures to arm64 for Release (or exclude armv7 via Excluded Architectures ).

Set Generate Debug Symbols to NO (note: debugging will be disabled).

Enable Deployment Postprocessing (YES for Release) and then configure: Strip Linked Product = YES Strip Debug Symbols During Copy = YES Symbols Hidden by Default = YES

Set Make Strings Read‑Only to YES.

Enable Dead Code Stripping (YES).

Pod optimisation – convert most pods to static libraries while keeping only required Swift pods as dynamic frameworks. Example Podfile snippet: # Podfile use_frameworks! dynamic_frameworks = ['xxx'] pre_install do |installer| installer.pod_targets.each do |pod| if !dynamic_frameworks.include?(pod.name) def pod.static_framework?; true; end def pod.build_type; Pod::BuildType.static_library; end end end end

Asset Catalog Compiler – set Optimization to space (use xcrun --sdk iphoneos assetutil --info Assets.car > Assets.json to verify).

Change Optimization Level to -Oz for aggressive size reduction.

Result of Xcode Optimizations

Starting from 22.9 MB, after applying Pod optimisation the size became 21 MB; after Asset Catalog optimisation it dropped to 20.7 MB; after the remaining Xcode settings the IPA reached 13.2 MB (Architecture set to arm64 ).

Content

Size (after full Xcode optimisation)

_CodeSignature

67 KB

.lproj

4 KB

Frameworks

11.1 MB

Plugins

83 KB

Assets.car

4.7 MB

Executable

10.3 MB

Other resources

1.4 MB

Resource File Optimisation

Resource optimisation is an ongoing task. It consists of two phases: removal of unused assets and compression of used assets.

Unused resource removal – use tools such as AppCode static analysis (Unused code, Unused imports, etc.) and LSUnusedResources to find orphaned images, JSON, audio, and duplicated third‑party SDKs.

Compression of used resources – Compress PNGs (Xcode’s Compress PNG Files can be turned OFF if you pre‑compress). Remove text metadata from PNGs. Use resource_bundles in CocoaPods to avoid name collisions. Prefer IconFont for simple icons. Batch compress images via TinyPNG API (script BatchProcessImage ). Place 2x/3x images in .xcassets so only the needed resolution is bundled; large images (>100 KB) should be stored as WebP. For private pods, add an Images.xcassets bundle and reference it via resource_bundles . s.resource_bundles = { 'xxsdk' => ['xxx/Assets/**/*.xcassets'] }

Result of Resource Optimisation

After resource optimisation the IPA size decreased from 13.2 MB to 10.3 MB. Notable changes:

Content

Size (after resource optimisation)

Frameworks

11.1 MB

Plugins

83 KB

Assets.car

2.4 MB

Executable

10.3 MB

Other resources

952 KB

Monitoring Mechanism

To prevent regression, the author suggests a post‑build script that compares the current IPA size with a baseline; if the increase exceeds a threshold, an email alert is sent. Additionally, maintain documentation of size‑changing events and enforce a development workflow that includes size checks for new libraries, assets, and deprecated modules.

Conclusion

Through Xcode build‑setting tweaks and systematic resource compression, the author reduced an initial 22.9 MB IPA to 10.3 MB without changing business logic. Further reductions are possible by replacing Swift third‑party libraries with Objective‑C equivalents, which will be covered in a future article.

References

Package Size Reduction – Various industry articles (Douyin, JD, Toutiao, etc.)

iOS 11 Development Guide (promotional section at the end of the original article)

mobile developmentpackage-sizeoptimizationiOSresource managementXcodeBuild Settings
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login 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.