Hi 👋

  • Wechat: RyukieW
  • 📦 Technical article archive
  • 🐙 making
My personal project Mine Elic endless sky ladder Dream of books
type The game financial
AppStore Elic Umemi


App weight loss is a commonplace topic. Apple has its own plans for app slimming. This article will be combined with official documents to elaborate.

1. What is application slimming?

On iOS, tvOS, and watchOS, the AppStore and operating system tailor and optimize apps according to the performance of users’ devices and operating systems. This optimization process is called application slimming.

  • You can create fully functional, continuously updated apps with minimal space
  • Faster download speeds
  • More space to install other apps
  • Bring a better user experience

2. Slicing (iOS, tvOS)

Slicing is the process of creating and deploying different application packages for different devices and systems. Each variant contains only the resources and executables required by the current device and operating system. You just need to package and upload the full version of the app to AppConnect. The AppStore will be created and distributed in different variations for different devices and operating system versions.

Use asset to store image resources so that the AppStore can select resources to load for different variants. When users install the application, they download and install a variant for their device’s system version.

Xcode will simulate Slicing during local build and run. When you archive, Xcode will include all builds and allow you to export the variants.

The figure below illustrates this process very well


It is mentioned here that the asset will load resources according to the architecture, so we usually do not put resources directly into the Bundle, and skip this optimization process.

Third, Bitcode

Bitcode is a layer of indirection for the compiler. Apps you upload to AppConnect with Bitcode open will be compiled and linked in the AppStore. Including Bitcode will allow Apple to optimize your application package in the future without having to re-upload it.

For iOS applications Bitcode is optional by default. WatchOS and tvOS are mandatory. If you want to support Bitcode, all the libraries you use should support Bitcode.

The symbol table

Xcode hides your app’s symbol table by default, so it’s not visible to Apple. You can choose to include the symbol table when you upload your App to AppConnect. Including the symbol table will allow Apple to provide you with a crash log.

If you want to collect crash logs yourself, you don’t have to upload symbol tables. You can download Bitcode’s compiled symbol table after you publish the app.

ODR: On-demand Resources (iOS, tvOS)

These resources are mainly pictures and sounds. The AppStore stores it on apple’s servers. The AppStore will use resources to optimize the bundle as needed. This will be shortened to ODR.

The ODR provides a better user experience:

  • Apps are smaller, faster to download, and faster to start up
  • Resources are downloaded in the background
  • The operating system will clean up when the disk resources are insufficientODR

4.1 Usage Guidelines

The App requests these resources, and the operating system downloads and stores them. The application uses the resource and then requests. After downloading, resources may remain on the device through multiple startup cycles, making access faster.

Resources can be any type of resource supported by the Bundle, except for executables. Table 1-1 shows the supported on-demand resource types and indicates whether these types are included in the project as files or assets.

Table 1-1: On-demand resource types

Type Asset catalog File
Data file
OpenGL shader x
SpriteKit particle x
SpriteKit scene x
SpriteKit texture atlas
Apple TV Image Stack

Data files can contain any type of data except for executable Swift, Objective-C, C, or C++ code. The files generated by the scripting language can be loaded on demand.

4.2 Benefits of the ODR

  • Smaller application size.
    • Users download smaller bundles of apps, resulting in faster downloads and more storage on the device.
  • The application resource is loaded lazily.
    • The application’s resources are only used in certain states. Resources are required when the application can enter the appropriate state.
    • For example, in a game with multiple levels, the user only needs resources related to the current and next levels.
  • Remote storage rarely used resources.
    • This resource is rarely used. Provide resources on demand.
    • For example, an application tutorial is usually displayed once the application is first opened and may never be used again. The application requires that the tutorial be requested the first time it is started, and then only when new features are needed or added.
  • Remote storage of in-application purchased resources.
    • If the application offers in-app purchases, include other resources. After the application starts, it requests to purchase the resources of the module.
    • For example, users buy emojis in keyboard apps. The application requests the package after startup is complete.

Five, ODR label working principle

Identify resources that are loaded on demand during development by assigning one or more tags. The tag is the string identifier that you create. You can use the name of the tag to identify how the contained resources are used in your application. For example, in a game, the tag Level-5 is used to handle every resource associated with Level-5.

  • At runtime,
    • Request access to a remote resource by specifying a set of tags. The operating system downloads resources labeled with these tags and stores them until the application runs out of them.
  • When the operating system needs more storage
    • It clears the local cache associated with one or more tags that are not being used.
    • The marked resource set may remain on the device for a period of time before being cleared.

5.1 Game Examples

Continuing with the game example, in a game divided into multiple levels, the user only needs resources related to the level the user is playing at and the next possible level.

The following figure shows an application that contains all resources at all levels.

You can reduce the size of application packages by creating labels for different levels and for other shared resources that do not need to be included in the application.

The following figure shows a smaller application with a marked resource set hosted inApp StoreOn.

5.2 Additional Settings

You can specify

  • A label that must be loaded when an app is installed from the app store
  • Set load priority for resource requests
  • Tracking download Progress
  • As well asSets a save priority for download labels that are no longer in use

Life cycle of the ODR

  • When the user first starts the application, the only on-demand resource on the device is forPre-matched resources.
  • When a user interacts with an application, the application requests a tag that represents a set of resources, uses the resource associated with the tag, and then informs the operating system that it has run out of tags.
  • The operating system clears one or more labels at a later, appropriate time.

Applications request by label, not by specific resource.

6.1 share the ODR

When you develop an application using the ODR, you may notice that requesting a tag downloads other tag-related resources as well. This is because the operating system works with optimized asset bundles for downloading shared resources. A tag can exist in multiple assets. When building an application, the Asset is generated by Xcode.

  • An example is a game in whichLevel 1andLevel 2Tags share some resources.XcodeTo generate threeAsset:
    • Level 1. OnlyLevel1The label
    • Level 2. OnlyLevel2The label
    • Level 1 + Level 2. BothLevel1The labels andLevel2The label

6.2 process

1. The application requests the label from the operating system. The operating system converts the required labels into a set of asset packages containing the associated resources.

Apply the resources associated with the Level1 and Forest tags in the following figure.

2. LabelAssetIs in local storage, the life cycle is moved toStep 6.

3. One or more labelsAssetHosted inApp StoreEither because it is the first release of the application, or because resources previously loaded on the device have been cleared (see below)Step 9).

In the image below, all the ODRs are in the app store.

4. The operating system starts to download resources that are not stored in the local storage.

5. Related to the required labelAssetThe resource is downloaded to the device.

In the figure below, the resources associated with the Level1 and Forest tags are downloaded to the device.

6. If the resources related to the required label are downloaded successfully, or if the resources are already in the device storage, the operation will be addedAssetAnd notifies the application that the requested label is available.

In the figure below, the application is told that the resources associated with the Level1 and Forest labels are available.

When tags are available, the application uses the resources associated with those tags. The ODR is accessed in the same way as the resources bundled with the downloaded application. The following figure shows the downloaded resources as virtual members of the application.

7. The application notifies the operating system that it has completed the use of the requested label.

8. The operating system releases labels on the local storage. This is done by reducing the amount associated with labelsAssetFor reference counting.

Making another request for a label already used on the device moves to Step 1.

9. The OS clears and from the local storageAssetRelated cache resources.

  • When any request is no longer associated with a tag,AssetYou can clean it up. Tag-related resources may remain on the device for a period of time before being cleared, including across applications (appgroups).
  • Making another request for the tag moves the lifecycle backStep 1.
  • You can influence the clear order by setting a save priority for labels.


This article is just a preliminary to the ODR has a preliminary understanding of the whole. A lot of the details haven’t been covered yet like how the project is configured, how the code is written. I’ll explore this further in a future article.

Welcome to click like to follow the collection ~


  • What is app thinning? (iOS, tvOS, watchOS)
  • On-Demand Resources Guide
  • NSBundleResourceRequest