IOS 9 App slimming function
Introduction to App slimming
There are a large number of iOS devices on the current market, so there are a variety of screen sizes and resolutions, A large amount of resources (such as png, jpeg, and binary PDF) are required to ensure that an App is displayed on multiple screens ). Unfortunately, this causes users to download a huge package (the previous iOS version forced users to download all the App files, including iPad images that they will never use when using the iPhone ). There are still many users using the 16G iPhone (and it may not disappear in a short time), so you need to reduce the App size so that you can download it quickly and ensure that users have enough space. The App slimming feature makes all this possible.
In addition to code and images, the current App also includes executable code and 32-bit and 64-bit versions (optimized for various architectures, such as arm64, arm7S, and arm7), 3D graphics technology (such as OpenGL, Metal, etc.), sound and other files. In short, the current App has become incredibly complicated. This is the problem that needs to be solved for App slimming.
App slimming automatically detects the user's device type (such as the model name) and downloads related content for a specific device. In other words, if you use iPad Mini 1 (no Retina screen, only 1X resolution), only 1X files will be downloaded. Resources with greater clarity (such as iPad Mini 3 or 4) will not be downloaded. Because the user only needs to download the content he/she needs, this accelerates the download process and saves space on the device.
Although this may sound complicated at first, we will go deep into the details. Fortunately, Xcode and AppStore will complete most of the work and developers will be much easier. Therefore, this tutorial does not contain too much code, but focuses on understanding the process of App slimming and the technologies it uses.
App slimming has three main aspects: Application slicing (App Slicing
), Intermediate code (Bitcode
) And load resources as needed (On Demand Resources
). In this tutorial, we will introduce them one by one.
App Slicing)
Slicing is the first thing we will discuss about App slimming ). According to Apple's documents,
Slice is a variant of the application package that creates and provides different target devices (variant
.
A variant (variant
Only resources required by the executable architecture and target devices are included. In other words, application slicing only provides resources related to each device (depending on the screen resolution and architecture ). In fact, application slicing completes most of the work of App slimming.
If you are ready to submit the App, you will upload it as before. IPA or. app file to iTunes Connect (but Xcode7 must be used because it contains iOS 9 SDK that supports App slimming ). Then, the AppStore slices the App and creates a specific variant (variant
), These variants will be based on the function (capabilities
) Distributed to each device ,.
Load Resources On Demand (On Demand Resources)
To fully understand App slimming, you need to know what resources are loaded on demand (ODR
). Resources loaded on demand are the files to be downloaded after the App is installed for the first time. For example, a specific game level (and content related to these levels) can be downloaded only when the player is unlocked. In addition, early levels that are not required by gamers can be removed after the preset time is exceeded to save device storage space.
In Xcode settings (in Build Setting), Enable On-Demand Resource loading and change "Enable On Demand Resources" to "YES ".
Intermediate code)
The last part of App slimming is the intermediate code. The intermediate code is a bit abstract, but in essence, it is a new way for Apple to optimize the App before it is downloaded. The intermediate code allows the App to run as quickly and efficiently as possible on any device. The intermediate code can automatically compile the App for the recently used compiler and optimize the specific architecture (such as arm64 64-bit processors, such as iPhone6s and iPad Air 2 ).
The intermediate code will be used together with other slimming techniques mentioned above to remove the Optimization content for other architectures and download the Optimization content to reduce the size of the downloaded files.
In iOS, intermediate code is a new feature and needs to be manually enabled in the new project. In this process, Enable bitcode can be changed to YES under Build Setting.
Use apps to slim down in your project
Although Xcode and App Store process the vast majority of App slimming processes, you still need to take some preventive measures to ensure that your App actually uses this new technology. First, you must use the Resource Directory (asset catalogs
). At this point, most apps use the Resource Directory by default (asset catalogs
). If you haven't used the Resource Directory (asset catalogs
), Most of your existing content can be transferred to a directory. You only need to click the "Use Asset Catalog" button in Xcode project settings, as shown below.
One of the new features of Xcode isSprite Atlases
. Sprite Atlases basically combines the Resource Directory and SpriteKit (the technology used to develop 2D games in Xcode ). Similarly, if you use SpriteKit, App slimming is required.
Test App slimming
As you can see, Xcode and Apple's AppStore have processed the vast majority of App slimming processes, which makes it much easier to use this technology in your own apps. But how can I test your App and make sure it has already been applied? Fortunately, Apple's TestFlight provides the perfect solution. In addition to the app slimming Technology of AppStore, TestFlight users can also experience this feature.
In the second part of this tutorial, we will introduce how to use App slimming in TestFlight.
First, download this basic blank project, decompress it, and run it in Xcode. You will notice that this project has nothing except in the Resource Directory (asset catalogs
). This resource directory (asset catalogs
.
First, run the App on the simulator or on the real machine. Open the setting application, and clickStorage and use of iCloud
This item (if it is not an iOS 9 device, clickStorage
) And select Manage bucket. Slide down to the App we just compiled and click it. You will notice that it is about 17.0 MB (this size may be slightly different when uploaded to iTunes Connect ).
When you build and run an App using Xcode, Xcode does not automatically process App variants (variant
) And the App is reduced, so the entire App file is on your device.
Next, clickProduct
Label, selectArchive
.
Note: you may need to modifyBundle Identifier
To match a self-created identifier. Otherwise, the App will not be uploaded to iTunes Connect.
Make sure that you select Include bitcode before clicking "Submit ". If everything goes well, you will see a green check mark notifying you that this build has been uploaded.
Now, log on to iTunes Connect and create a new App (including the appropriate bundle ID and App name ).
Add yourself as an internal tester. Note that it is common that a build remains in the "processing" status for several hours. Once the App is processed, select it and press the start test button.
An email will be sent to your address. Make sure you are using the iOS device you want to test. Open this email. You will enter the TestFlight application.
Install this build. Once the installation is complete, go back to the setup application, find the storage, and find the App as before. Note that the App is close to 5.4 MB. This is the significance of App slimming.
Wow! You just removed 12.4 MB from your App, and this is just a very simple App. Which contains a variety of different resources (asset
.
Summary
In this tutorial, we see the powerful App slimming. We have discussed three main aspects of App slimming: Application slicing (App Slicing
), Intermediate code (Bitcode
) And load resources as needed (On Demand Resources
).
Unfortunately, on June 14, September 24, 2015, Apple announced on its developer portal that App slimming has been delayed and will not be included in the public release of iOS 9 (or 9.0.1:
Currently, application slicing cannot be used for iOS 9 apps. Due to problems with creating an iOS 9 backup by iCloud, some apps in the AppStore can only be restored to iOS devices of the same model.
When users download your iOS 9 app, they will get a general version instead of a specific variant of their device type (vatiant
). TestFlight will distribute variations to internal test users (vatiant
). Application slicing will be available in future software updates. You don't need to do anything now.
However, as I mentioned at the beginning of this article, App slimming has been fixed and is ready for all devices running iOS 9.0.2. App slimming is an incredible tool that will continuously accelerate App downloads.