Search Unity

App slicing is a new iOS feature available since iOS and tvOS version 9.0. It’s purpose is to reduce the size of the main application bundle by allowing developers to upload several device-dependent versions of resources to the App Store. Only one out of these is included in the App bundle for the device of the particular user.

App slicing is very useful on iOS platform, because it helps the developers to pack more assets into the initial app bundle and still stay within the 100MB over-the-air download limit. To achieve this objective, the developer may also use the counterpart of app slicing, on-demand resources, which we have covered previously. However, in order to use on-demand resources, the app needs to be adapted to download needed resources dynamically, which is not always convenient or optimal. It’s also more complex in all cases. App slicing does not have these drawbacks.

There are two flavors of app slicing: app executable slicing and app resource slicing. The former refers to removal of unneeded executable code from the application bundle and is employed automatically on the App Store for all apps that target iOS/tvOS version 9.0 and higher. The latter refers to removal of unneeded assets and needs more developer effort in order to work. This is what we will cover in this blog post.

The primary objective of app resource slicing is to reclaim wasted bandwidth and space in cases when there are several variants of the same asset. Usage of different asset variants is frequently needed because there is large difference of hardware capabilities between the most recent and older, but still widely used iOS devices. Most of the time developers need to use assets of different quality to fully utilize the most performant devices without penalizing the rest. Prior to iOS 9.0, all asset variants had to be included into the main app bundle. That wasted bandwidth and storage space on devices, as all but one asset variants were unused. By employing app resource slicing, it’s possible to exclude any unneeded assets from the application bundle.

The most convenient way of taking advantage of app resource slicing is via asset bundles. They are the easiest option for adapting the layout of the application assets for slicing. Asset bundles are integrated within Unity and the performance is effectively equivalent to loading from regular data files. Asset bundles are also used as the backend for on-demand resources, thus it’s convenient to add app thinning support to an app that already uses on-demand resources or vice-versa. Once asset bundles are configured, you need very few additional changes to use app resource slicing, as shown in the code examples below. In this blog post, we won’t cover asset bundles. If this is the first time you hear about them, this resource will help you.

In order to use app resource slicing, the developer needs to specify which devices are eligible for all variants of assets that need to participate in resource slicing and then load the assets during application startup. In vanilla iOS app development, this is done by creating data set or image set items within an asset catalog, setting up device variations and then assigning resources to the placeholders in the UI. In Unity, the developer needs to set up asset bundle variants, that is, several asset bundles containing the same set of assets assets themselves potentially being different. All asset bundle variants that participate in app resource slicing need to be registered in code using UnityEditor.iOS.BuildPipeline.collectResources callback API. Later, the exact device requirements are specified in the player settings UI. Finally, the developer needs to manually load asset bundle via AssetBundle.CreateFromFile API on application startup.

The following two code examples demonstrate the essence of using app resource slicing:

Editor script to register resources that should participate in app resource slicing:

Loading of asset bundles during startup:

The easiest way to start exploring asset bundles and app resource slicing is to use our Asset Bundle Manager demo project, which is available on BitBucket. The landing page offers a comprehensible description of how to use and tweak the demo.

11 replies on “Optimizing iOS app size with resource slicing”

I can’t seem to find InitializeOnLoadMethod.

Which version of Unity has this method?

In 5.3.2p3 I see RuntimeInitializeOnLoadMethodAttribute which isn’t the same.

Could you point me in the right direction?


[…] via Optimizing iOS app size with resource slicing – Unity Blog. […]

hello there now i’m generate this amazing site concerning which attention to be able to Audio iles, gastronomie, insular motion picture, Insular publication, in order to get involved with this function would certainly can you check out festival

Soooo, it’s 12 days into 2016 and you guys don’t want to blog about anything? really? nothing? not even two lines to wish us a happy new year?

Anyways, have a happy new year to you all. Looking forward to all the stuff on the road map for 2016 to come into fruition!


i’m sorry if it off with this post, but i don’t know where to put this.

the RSS feed in all categories inside this blog seems no longer to be updated. it was make me thought that this blogs not been written for three months, until i realize that the RSS got stuck in “get even more from ….”, i’m still use this feature so please fix it.

Comments are closed.