iOS App Package Size Optimization: Strategies and Practices at ByteDance
This article details ByteDance's iOS team approaches to reducing app package size—including resource compression, Assets.car merging, text file zipping, and Mach‑O binary optimizations such as -Oz, LTO, exported symbols, property dynamic handling, __TEXT segment migration, and binary segment compression—resulting in multi‑megabyte savings and improved download performance.
Since 2016, ByteDance's iOS team has been focusing on app package size reduction and previously published an article on the topic; the current update adds new techniques discovered over the past three years, covering build configuration, image compression, __TEXT segment migration, and binary segment compression.
The final ipa, after App Slicing, consists of resources and the Mach‑O executable; resources mainly include the Asset Catalog output file Assets.car and other assets, both of which are primary targets for size optimization.
Resource size optimizations include:
Setting the deployment target to iOS 9 and enabling ASSETCATALOG_COMPILER_OPTIMIZATION to let actool choose more efficient encoding algorithms, saving 2.31 MB.
Applying RGB‑with‑palette compression via ImageOptim with flags such as --number-of-colors 16 --quality 40-80 to achieve a 3.15 MB reduction.
Merging multiple Assets.car files from different Pods into a single catalog, eliminating duplicate BOM blocks and gaining 2.1 MB.
Compressing text resources (JSON, HTML, etc.) during the build phase, storing them zipped, and decompressing at runtime, which saved around 400 KB for Lottie JSON files.
Mach‑O binary optimizations include:
Enabling the -Oz compiler flag, which reduces binary size by over 4 MB.
Activating Link‑Time Optimization (LTO), yielding a 6.5 MB reduction.
Configuring EXPORTED_SYMBOLS_FILE to hide private symbols, saving 2.1 MB.
Marking properties as @dynamic and generating getters/setters at runtime, cutting roughly 800 KB.
Migrating __TEXT sections to __BD_TEXT to shrink the encrypted region, decreasing download size by 60 MB and install size by 2 MB.
Compressing selected binary sections ( __TEXT , __gcc_except_tab , __objc_methtype ) and decompressing them on demand, saving an additional 3.5 MB.
Combined, these measures keep the app size stable despite rapid feature iteration, and the team continues to collaborate with product groups to eliminate unused code and resources.
The article concludes with an invitation to join ByteDance's iOS platform architecture team, highlighting the need for engineers passionate about performance optimization and large‑scale mobile development.
ByteFE
Cutting‑edge tech, article sharing, and practical insights from the ByteDance frontend team.
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.