Avoid Many Files (iOS)

Every file in your app has extra overhead that can bloat your app size. In the _CodeSignature folder of an app bundle you'll find a plist file named CodeResources. This contains a collection of every file in the bundle and a signature of the contents. The data is used by iOS to validate an app is not modified.

<dict>
	<key>files</key>
	<dict>
		<key>[email protected]</key>
		<data>
		/1UymLY9lYt+mYZPDnqAyaodgeE=
		</data>
		<key>AppIcon76x76@2x~ipad.png</key>
		<data>
		0fo27RIQex7xfxfz11SWPqh1Yts=
		</data>
		<key>Assets.car</key>

As you can see, the file will increase in size as more files are included in your app. For apps with 10k+ files this overhead becomes >5mb. The problem only gets worse if files are included in a framework since frameworks have their own copy of the CodeResources.

There is an easy fix, be aware of what files your app uses and move loose files to compiled asset catalogs when possible. Emerge will warn you if many files are found in the app.

Small Files

Files under 4kb have the same code signature overhead as any other file, but they are even more inefficient in terms of install size. Each file has a minimum allocation size at the file system level. This means a 4kb minimum allocation size causes one thousand 1kb files to take up 4 MB.

512

The macOS inspector shows the difference in size between a file's contents and disk space used.

This seemingly tiny issue can add up very fast and bloat install size, giving users less space their device. We recommend merging small files such as localized strings into a single file, and moving other into asset catalogs.