App Thinning in Xcode Summary

Excerpt From: Apple Inc. App Thinning in Xcode. https://developer.apple.com/videos/wwdc/2015/?id=404

There are many advantages of having a small sized application such as supporting devices with constrained storage, shorter download times, easier to stay within over-the-air size limits, supporting more types of devices, adding features that couldn't previously fit, just to mention a few. Broadly, an app can be partitioned into two parts: one is executable, another is resource. If your app's resources take up too much space, then this apple tech talk is right for you. Take Apple's application DemoBots for example, the universal app is 74MB, and by thinning it out, they get between 16MB and 29MB, 22MB on the average. After further optimization with on demand resources, the size of the app can be reduced to 14MB on average.

There are two things you can do to minimize the app size:

  1. Asset Slicing.

You've probably already been doing it -- using Asset Catalogs. That's it! This is all you need to do to get the advantage of app slicing. Integration Bots will pre-build all app variants for different devices so that each device will download an app with only needed assets. The key is to cataloging efficiently. Robust markup means less redundancy in sliced application variants.

App Thinning in Xcode Summary_第1张图片
before
App Thinning in Xcode Summary_第2张图片
after

Q&As:

  1. How to intergrate with Your Xcode Project?
- Project must have an xcasset folder reference.
- Place any externally generated content within xcassets folder.
- No limitations on file hierarchy.
  1. Xcode Build and Run automatically thins resources for the active run destination. How to turn the feature off?

    Disable ENABLE_ONLY_ACTIVE_RESOURCES in target build setting.

  2. On demand resources.

Some things are always needed, such as executable and basic interface. Other things may be needed only later, like an advanced level in a game. Still other content might never been needed, an example is a tutorial that the user only watches once.

You could partition assets into tagged groups using Xcode. Tags are simple strings and might be single files or an entire folder. Type of content that can be tagged are images, sounds, data, scripts, in-app purchased content and no executable content.

App Thinning in Xcode Summary_第3张图片
before
App Thinning in Xcode Summary_第4张图片
after
// APIs for retrieving resources with tags
class NSBundleResourceRequest {
   convenience init(tags: Set) // initialize with set of tags
   func beginAccessingResourcesWithCompletionHandler((NSError?)->void) // begin a request
   func endAccessingResources() // tell the system you're finished
 }

你可能感兴趣的:(App Thinning in Xcode Summary)