30
App Thinning Neo

App thinning

Embed Size (px)

Citation preview

App Thinning

Neo

OutlineWhat’s App Thinning in iOS 9 Slicing (iOS) Bitcode On-demand Resources

What’s App ThinningNew feature in iOS and watchOS According to variant devices to optimize App

App size Efficiency Spacing Minimal footprint

Three components of App thinning Slicing Bitcode On-demand resources

Slicing (iOS)Slicing is the process of creating and delivering variants of the app bundle for different target devices.

App always have universal resource, and that’s very fat.

Slicing (iOS)

Slicing can export variant of the App bundle

Slicing (iOS)

How to use the capability Just one additional step during run or distributing App. After completed the step, developer can export variant of app bundle to test, or run on simulator.

Slicing (iOS)

The step can help you Specific App bundle resource for variant of devices to reduce App size. Ex: iPhone 6 plus will only download the App bundle of ARM 64 bit architecture @3x image resource.

The most important Slicing is only supported on latest iTunes and iOS 9.0 or later Image resource must establishes on asset catalogs If image resources come from external asset, make a simple folder structure and JSON markup

Slicing (iOS)

Using asset catalogs to adapt slicing

Slicing (iOS)

Using custom folder to adapt slicing Simple folder structure, just like Xcode asset but must have JSON markup Place any resource within xcasset folder reference

Slicing (iOS)

Must included JSON Markup to tell system how to retrieve image

Slicing (iOS)

“Bitcode is an intermediate representation of a compiled program.” - App Distribution Guide

It is the same as byte code, but compiled by llvm. Sent it to Apple which allow Apple to re-optimize you App without new version App In iOS is default but optional, but required in watchOS.

Bitcode (iOS, watchOS)

On-Demand Resources (iOS)On-demand resources are that separated App resources and hosted on Apple servers.

Download what user needs to download More space efficiency Remove resources when they are nolonger needed and disk space is low Work transparently in the background

Ex: A game App

On-Demand Resources (iOS)

On-Demand Resources (iOS)

On-Demand Resources (iOS)

On-Demand Resources (iOS)What type of resources can be on-demand

On-Demand Resource Size Limits

On-Demand Resources (iOS)Setting up On-Demand Resources

https://developer.apple.com/library/prerelease/ios/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/index.html#//apple_ref/doc/uid/TP40015083-CH2-SW1

Using NSBundleResourceRequest to manage On-Demand Resource

Request access to on demain resource Update the priority of a download Track the progress of a download Notifying the OS when access is no longer needed Check for a notification of low disk space

On-Demand Resources (iOS)Request access to on demain resource

Tags of one App Bundle is managed by one instance of NSBundleResourceRequest Request resources before user need (ex: In game, load stage 2 in stage 1) Step1 - Initial NSBundleResourceRequest

On-Demand Resources (iOS)Step2 - Requesting access to the on-demand resources

Download the resources from the App storea. error == nil (downloaded successfully) b. callback is not at main thread

Does not download the resources a. only check resources available in local b. resourceAvailable = NO (resources are not ready)

On-Demand Resources (iOS)

On-Demand Resources (iOS)Update the priority of a download

Change priority to ensure OS resources - App performance Priority can be changed any time, including during the download.

Track the progress of a download

On-Demand Resources (iOS)Pausing and Canceling

On-Demand Resources (iOS)Notifying the OS when access is no longer needed

When resources end access, allow the OS to release the storage on the device Two way end access 1. Send endAccessingResources 2. Deallocate the resource request

On-Demand Resources (iOS)Setting Preservation Priority

OS will purge tags from lowest preservation priority

On-Demand Resources (iOS)Check for a notification of low disk space

Notification send out when it is no enough space for current request

On-Demand Resources (iOS)Debugging On-Demand Resources

Three main categories of problems: Networking connectivity, local storage space, and Unexpected State Check unexpected state in Xcode

On-Demand Resources (iOS)Unexpected State list

References

WWDC 2015 Section 404 - App Thinning in Xcode

https://developer.apple.com/videos/wwdc/2015/?id=404

App Distribution Guide https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html

On-Demand Resources Guide https://developer.apple.com/library/prerelease/ios/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/index.html#//apple_ref/doc/uid/TP40015083

Q & A