Pinterest Liang Ma Apr 16, 2021

How We Reduced Pinterest’s iOS App Size by 30+% / 50MB

Article Summary

Pinterest slashed their iOS app size by 30% (50MB) and immediately saw install rates climb. The culprit? A sneaky localization bug multiplying files across app extensions.

Pinterest's iOS team discovered their Bazel build system was duplicating localization files into every app extension, bloating the bundle unnecessarily. Engineer Liang Ma shares how they diagnosed and fixed this architectural issue.

Key Takeaways

Critical Insight

A single architectural fix eliminating duplicate localization files reduced Pinterest's iOS app by 50MB and boosted installs.

The team reveals why NSLocalizedString was the real villain and their long-term strategy for truly modular extensions.

About This Article

Problem

Pinterest's CI job used Bazel query to scan source code and send strings to Mojito for translation. When app extensions were added, each extension's BUILD file copied the entire Localizable.strings file into its own bundle. This created duplicate copies across multiple extension modules.

Solution

Liang Ma's team fixed the extension BUILD files to stop copying localized strings from the main app bundle. They also updated NSLocalizedStringWithDefaultValue calls to explicitly reference the main app bundle path instead of relying on +[NSBundle mainBundle], which was returning the extension's subfolder path.

Impact

The fix reduced app size by approximately 50MB, which was 30% of the total app size. This came from removing duplicate Localizable.strings files across all extensions. After rolling out the change in Pinterest iOS v9.1, the team saw measurably more app installs on new versions.