How to Shrink iOS App Package Size: A Practical Optimization Guide
This article walks through a complete iOS package size reduction process, covering IPA structure, detailed component analysis, Xcode compile settings, code and resource optimizations, monitoring scripts, and best‑practice guidelines to keep the app lean and stable.
Background
Recently the team was assigned a package‑size monitoring metric. The author had previously worked on package‑size optimization, so this article records a full iOS package‑size optimization workflow to help anyone facing similar challenges.
iOS (Installation) Package
The ipa (iPhone Application Archive) is the iOS installation package, typically named xxx.ipa.
iOS Package Contents
To optimize, you first need to know what is inside the package. Rename the .ipa file to .zip and unzip it. The main components are: _CodeSignature: signature files Assets.car: compiled asset catalog (stores images, etc.) embedded.mobileprovision: provisioning profile Info.plist: project configuration Plugins: extensions such as Widget, Push, Share .Iproj: language files exec: executable files (e.g., widgetExtension)
Image resources: .png, .jpg, .webp, .gif Other resources: .xml, .json, .plist, .bundle, .conf, .cer/.der/.p12, .wav, .js, .html, .nib, .sqlite, .txt, .mom Before optimization the IPA size was 76.5 MB and the unzipped size 140.1 MB . The size breakdown (in MB) was: _CodeSignature: 1.8 Assets.car: 0.518 (partial use) embedded.mobileprovision: 0.055 Info.plist: 0.016 Plugins: 2.7 .Iproj: 0.002 exec: 104.9
Image resources: 16.7
Other resources: 13.4
Optimization Strategies
After understanding the package composition, the author applied three layers of optimization: Xcode compile settings, resource file optimization, and code optimization.
Xcode Compile Optimization
Key steps:
Set Architectures to arm64 only, removing 32‑bit armv7.
Set Optimization Level to -Oz for release builds (size‑focused).
Configure Asset Catalog Compiler Options → Optimization to space to compress Assets.car.
Disable debug symbols: Generate Debug Symbols = NO.
Enable stripping of linked products and debug symbols during copy via Deployment Postprocessing = YES, Strip Linked Product = YES, Strip Debug Symbols During Copy = YES.
Hide symbols by default in release: Symbols Hidden by Default = YES.
Reuse string literals: Make Strings Read‑Only = YES.
Enable dead code stripping: Dead Code Stripping = YES.
Disable exception handling when not needed: set Enable C++ Exceptions and Enable Objective‑C Exceptions to NO and add -fno-exceptions to Other Link Flags.
After applying these settings the compressed IPA reduced to ≈51 MB and the unzipped size to ≈90 MB . The executable shrank from 104.9 MB to 56.6 MB.
Code Optimization
Most code‑size reductions are achieved by the compile settings above. Additional static analysis tools (AppCode for projects under a million lines, Clang for larger codebases) can identify unused classes, methods, variables, imports, macros, etc.
Resource File Optimization
Two main directions:
Remove unused resources :
Unused code files (static analysis)
Deprecated business logic still present in the repo
Images that are referenced but never used
Duplicate third‑party libraries
Compress used resources :
Images < 100 KB: run through TinyPNG (multiple passes) or batch scripts.
Place images in xcassets so Xcode generates appropriate @2x/@3x assets and can create texture atlases.
Images > 100 KB: consider converting to WebP (supported by most iOS image libraries) or keep in .bundle if necessary.
Compress HTML/JS with H5 minifiers before bundling.
Move large JSON files to a server and fetch at runtime.
Compress audio using the highest‑quality codec acceptable to product.
Tools mentioned:
lipo -info xxx # shows architectures (e.g., armv7 arm64) # List of architectures and target devices (comments) xcrun --sdk iphoneos assetutil --info Assets.car > Assets.json # Install fdupes (brew install fdupes) # Scan for duplicate files id someClass = NSClassFromString(@"SomeClass");Monitoring Mechanism
After optimization, a script runs after each build to compare the new package size with the previous baseline. If the increase exceeds a predefined threshold, an email alert is sent to the responsible engineers. All size changes are logged, and the reasons are documented to prevent regressions.
Process Guidelines
When adding a new third‑party library, check for existing alternatives or possible in‑house implementations.
For new image assets, evaluate size, consider code‑generated alternatives, and compress appropriately.
Periodically clean up deprecated modules and unused resources.
Track package size per build, record causes of changes, and continuously refine the workflow.
Conclusion
Package size cannot be reduced once and forgotten; it requires ongoing vigilance, solid development standards, and automated monitoring to keep the app lean and stable.
References
Apple Xcode Build Setting Reference
Package size slimming article
ByteDance iOS package size optimization practice
Sohu Smart Platform Tech Team
The Sohu News app's technical sharing hub, offering deep tech analyses, the latest industry news, and fun developer anecdotes. Follow us to discover the team's daily joys.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
