Mobile Development 9 min read

Implementing iOS App Slicing with Asset Catalog and Build Scripts

This article explains how to use Apple's App Slicing feature on iOS by managing image resources with Asset Catalog, automating the process through Xcode build‑phase scripts, generating the Assets.car file with actool, and addressing practical considerations for large, multi‑module applications.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Implementing iOS App Slicing with Asset Catalog and Build Scripts

App Slicing, introduced by Apple in iOS 9, creates device‑specific app bundles by delivering only the image resources that match the target iPhone’s resolution, thereby reducing the final download size.

The article first describes the structure of an .ipa file, listing its components such as the app binary, Nib files, databases, image assets, and property‑list files. For apps that enable Slicing, image assets are compressed into a special Assets.car folder; otherwise each image remains as a separate file.

Using Xcode’s Asset Catalog, developers can add images in different resolutions (1x, 2x, 3x) to an Image Set. When the project is archived and submitted to the App Store, the Slicing process automatically generates device‑specific variants, ensuring each user receives only the appropriate resolution assets.

In large, long‑standing projects like the Ctrip app, most images are stored in ordinary resource folders, making manual migration to Asset Catalog impractical. The solution is to automate the migration with a Run Script phase in Xcode: the script recreates the Asset Catalog folder structure and generates the required Contents.json files for each image.

The Contents.json file contains key‑value pairs describing each image’s idiom, scale, and filename, as well as version information. After the simulated Asset Catalog is built, the script invokes the command‑line tool actool (found in /Applications/Xcode.app/Contents/Developer/usr/bin/ ) to compile the assets into an Assets.car bundle. The command requires the path to the Images.xcassets directory and a minimum deployment target of iOS 7.1 or higher.

Once the Assets.car file is generated, the app’s Slicing functionality is effectively enabled. Developers can verify the impact by comparing the sizes of the generated .ipa files for different devices; each device receives an optimized bundle containing only the necessary image resolution.

The article also notes important caveats: images managed by Asset Catalog must be loaded with [UIImage imageNamed:@"imageName"] , not with imageWithContentsOfFile: , and maintaining the migration script adds ongoing maintenance overhead. Additionally, App Slicing only works on devices running iOS 9.0.2 or later.

Reference resources include Apple’s documentation on reducing app size, iOS App Thinning, and the actool man page.

Mobile DevelopmentiOSAsset CatalogApp SlicingBuild Script
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

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.