IOS9 App Thinning (Application slimming) function introduction, ios9thinning

Source: Internet
Author: User
Tags spritekit

IOS9 App Thinning (Application slimming) function introduction, ios9thinning

After iOS9 is released, a bug occurs that prevents App Thinning from running properly. In iOS9.0.2, this bug has been fixed and the App Thinning can be used properly. Pay attention to this when you download an application from the App Store.
After iOS9 was launched, it was very popular. In just weeks, more than half of iOS devices have installed the new system. This is the fastest adoption speed in iOS versions of previous generations-and even broke the record set by iOS7 in 2013.
With regard to iOS9, I recently published an article titled Search APIs and SFSafariViewController. Today, I will continue to explore another exciting feature on iOS9-App Thinning ). In this tutorial, we will explore why App Thinning is important and how to use this exciting feature on your own App.

According to the release of WWDC, App Thinning is a new technology that can change the entire download process. Many users have responded that the traffic cost is too high and the storage space of iOS devices is limited, but the download speed is constantly improved. To adapt to these problems, App Thinning is very worth learning. In addition, the release of App Thinning has been postponed, and now is the best time to learn about this new technology.

Prerequisites
In this tutorial, I assume that you have practical experience with Xcode and know how to use IDE. If you do not know much about this or are not sure about the IDE, you may want to take a look at the excellent free courses related to this.
In addition, I assume that you know how to publish an App on the app Store and how to use Apple's Beta application testing service testflight. I will not explain how to use testflight in detail, so if you are not familiar with testflight or are not clear about the general process of uploading and publishing an app, I recommend that you take a look at this AppCoda article without any precondition except for these and your willingness to learn.
Let's get started on this premise.

Introduction to App Thinning

Today, there are a variety of iOS devices on the market, and the screen size and resolution are even more varied, which leads to an app wanting to have a good visual effect on multiple screens, A large amount of optimization resources (PNG, JPEG, and vector PDF files) are required to match screens of different sizes. Worse, this leads to a significant increase in user downloads. (In the previous iOS version, users are required to download the entire app file. Even if users are using the iPhone, they need to download ipad image files they will never use) the 16g iPhone still exists (it will not disappear in a short time). Therefore, making your App streamlined and quickly downloading can ensure that you have enough space, it also optimizes the user experience. App Thinning makes it all possible.
Today, apps no longer consist of simple code and images. Modern applications include not only executable code, but also different 32-bit and 64-bit versions (optimized for various architectures such as arm64, arm7s, and arm7 ), 3D graphics technology (such as OpenGL and Metal), as well as audio and other different files. In short, today's App functions are extremely complex. This is where Thinning plays a role.
App Thinning automatically detects the user's device type (that is, the model name) and only downloads the content applicable to the current device. In other words, if you are using an iPad Mini 1 (1x resolution and not a retina display), you will only download the files used for the 1x resolution (more details will be given below. Resources used by more powerful and higher-resolution ipad (such as iPad Mini 3 or 4) will not be downloaded. Because the user only needs to download the content required by the specific device he/she is currently using, this not only accelerates the download speed, but also saves the storage space of the device.
Although it may seem a bit complicated at the beginning, I will have a deep understanding of the details. Fortunately, most of this work will be done by Xcode and App Store, which makes the developer's life much easier. Therefore, the focus of this tutorial is to have a deep understanding of App Thinning and its implementation technology, without a lot of code.
App Thinning mainly has the following three aspects: App Slicing (Application division), Bitcode and loading resources as needed. In this tutorial, I will detail each aspect in detail.


App Slicing
Concerning App Thinning, the first aspect discussed in this article is the division problem. According to Apple's official document, "Slicing is the process of creating and distributing different variants for application bundle to adapt to different target devices. A variant only contains executable architectures and resources for a specific target device .」 In other words, App Slicing only transmits resources related to the device (depending on the screen resolution, architecture, and so on ). In fact, App Slicing is responsible for processing the main process of App Thinning.
When you are ready to submit an app, The. IPA or. App file is usually uploaded to iTtunes Connect (but Xcode7 must be used because it contains the iOS9 SDK that supports App Thinning. Then, the App Store splits the app and creates specific variants to adapt to different performance devices.


On Demand Resources

Load resources as needed
To fully understand App Thinning, you must understand how to load Resources (On Demand Resources, ODR) On Demand ). Loading resources on demand is a file that can be downloaded after the app is installed for the first time. For example, a player can download a new level (specific content related to this level) after unlocking a specific level of the game ). In addition, the level that players have passed can be removed to save storage space on the device.
Enabling the on-demand Resource loading function involves changing the Settings in Xcode (under Build Settings), and selecting "enable on-demand Resource loading" as yes 」.


Bitcode
The last aspect of App Thinning is bitcode. Bitcode is somewhat abstract, but in essence it is also a new way for Apple to optimize the app before users download it. Bitcode enables the app to run quickly and efficiently on any device. Bitcode uses the latest compiler to automatically compile apps and optimize specific architectures. (For example, arm64 for 64-bit processors such as iPhone 6 s and iPad Air 2)
Bitcode does not download application optimizations for different architectures, but only downloads optimizations related to specific devices, making downloads smaller. It also works closely with the aforementioned App Thinning technology.
Bitcode is a new feature on iOS, which must be manually enabled for new projects. You can set bitcode to YES by selecting the project Settings under Build Settings.


Apply App Thinning in your project
Although Xcode and App Thinning are responsible for handling the main process of App Thinning, you still need to take some preventive measures to ensure that your app supports this new technology. First, you must use the asset directory. The asset directory is enabled by default on most apps. If you have not enabled the asset directory, you can click "enable asset directory" in Xcode project settings to transfer many existing files to the directory.

Sprite Atlases is a new feature in Xcode7. Sprite Atlases is essentially a combination of asset directories and is also the core of SpriteKit (the technology that Xcode uses to create 2D games. Therefore, if you use SpriteKit, app thinning is required.

Test App Thinning
As mentioned above, Xcode and App Store are responsible for processing most of the App Thinning processes, making this technology truly easy to apply on your app. But what if you want to test your app to make sure it is ready for app thinning? Fortunately, Apple's TestFlight provides us with a perfect solution.
In the second half of this tutorial, I will discuss how to use App Thinning on TestFlight.
First, download this almost blank project, decompress it, and run it in Xcode. You will find that this project does not contain much content except the images under several asset directories (without a lot of code. The asset directory also contains the 1x, 2x, and 3x versions of the application icon.

First, run the application on the simulator or device. Open the setup application, click "storage space and iCloud usage" (only "Storage" On devices other than iOS 9), and then select "manage storage space 」. Scroll down to find the compiled application and click it. You will find that it is only about 17.0 MB (it may be slightly different when it is uploaded to iTunes Connect ).
Aa

When you use Xcode to compile and run an application, Xcode does not automatically process application variants and App Thinning. In this way, the entire application file is still on your device.
Click the Product tab of Xcode and select Archive ).

Note: you may need to modify the Bundle Identifier of the application to match your own program. Otherwise, the application cannot be uploaded to iTunes Connect.


Make sure that you select include bitcode before selecting submit 」. If everything goes well, you will see a green check mark indicating that your project has been successfully updated.
Click here to log on to iTunes Connect and create a new application (fill in the appropriate bundle ID and Application name ). If you are not sure how to do this, refer to the AppCoda TestFlight tutorial.

Add yourself as an internal tester. Note that it is not uncommon that the project is in the "processing" state for hours after being created. Once the application is processed, select it and press start to test 」.
You will receive an email. Make sure to use the iOS device you want to test and accept the email invitation. You will be taken to the TestFlight application.

Install this version. Then, return to application settings, browse storage, and find our previous application. The application is only 5.4 MB now. This is the masterpiece of App Thinning!

Wow! A very streamlined application saves 12.4 MB of storage space. Then, applications that contain multiple resources will get more significant changes in size!

 

Reference link:

Http://www.cocoachina.com/ios/20150612/12135.html

Http://www.jianshu.com/p/330303ac0410

 

2. Official website links: 

Http://help.apple.com/xcode/mac/current/#/devbbdc5ce4f

Official Website documentation

App thinning overview (iOS, tvOS, watchOS)

The App Store and operating system optimize the installation of iOS, tvOS, and watchOS apps by tailoring app delivery to the capabilities of the user's particle device, with minimal footprint. This optimization, calledApp thinning, Lets you create apps that use the most device features, occupy minimum disk space, and accommodate future updates that can be applied by Apple. faster downloads and more space for other apps and content provides a better user experience.

Slicing (iOS, tvOS)

SlicingIs the process of creating and delivering variants of the app bundle for different target devices.VariantContains only the executable architecture and resources that are needed for the target device. you continue to develop and upload full versions of your app to iTunes Connect. the App Store will create and deliver different variants based on the devices your app supports. use asset catalogs so that the App Store can select images, GPU resources, and other data appropriate for each device variant. when the user installan app, a variant for the user's device is downloaded and installed.

Xcode simulates slicing during development so you can create and test variants locally. xcode slices your app when you build and run your app on a device or in Simulator. when you create an archive, Xcode uses des the full version of your app but allows you to export variants from the archive.

Note: Sliced apps are supported on devices running 9.0 and later; otherwise, the App Store delivers universal apps to mers MERs.

Bitcode

BitcodeIs an intermediate representation of a compiled program. apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the App Store.

For iOS apps, bitcode is the default, but optional. for watchOS and tvOS apps, bitcode is required. if you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode.

Xcode hides your app's symbols by default, so they are not readable by Apple. when you upload your app to iTunes Connect, you have the option of including symbols. including symbols allows Apple to provide crash reports for your app when you distribute your app using TestFlight or distribute your app through the App Store. if you 'd like to collect and symbolication crash reports yourself, you don't have to upload symbols. instead, you can download the bitcode compilation dSYM files after you distribute your app.

On-Demand Resources (iOS, tvOS)

On-demand resourcesAre resources-such as images and sounds-that you can tag with keywords and request in groups, by tag. the App Store hosts the resources on Apple servers and manages the downloads for you. the App Store also slices on-demand resources, further optimizing variants of the app.

On-demand resources provide a better user experience:

  • App sizes are smaller so apps download faster, improving the first-time launch experience.

  • On-demand resources download in the background, as needed, while the user has es your app.

  • The operating system purges on-demand resources when they are no longer needed and disk space is low.

For example, a master-detail app may divide resources into levels and request the next level of resources only when the app anticipates that the user will move to that level. similarly, the app can request In-App Purchase resources only when the user makes the corresponding in-app purchase.

Note: If you distribute your app to registered devices (outside of the App Store), you must host the on-demand resources yourself.

To set up on-demand resources in your app, read On-Demand Resources Guide and NSBundleResourceRequest.

Was this help page useful? Send feedback.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.