With so many iOS devices on the market currently and a plethora of screen sizes and resolutions available, making an app look great across multiple screens requires optimizing assets (i.e. pngs, jpegs, and vector PDFs) for each screen size. Worse, this results in a massive download for users (previous version of iOS forced users to download the entire app file, including the images they would never use such as iPad images even if they’re using an iPhone). 16 Gigabyte iPhones still a very real reality (and likely not going away any time soon), so making your app lean and a quick-to-download ensures that users have enough space as well as optimizes the entire experience. App thinning makes this possible.
Today, apps are made of much more than just code and images. Modern apps include not just executable code, but 32, 64 bit versions (optimized for various architectures such as arm64, arm7s, and arm7), 3D graphics technologies (i.e. OpenGL, Metal, etc.), audio, among other files. In short, the caliber of apps today are incredibly complex. That’s where app thinning comes to the rescue!
App thinning automatically detects the user’s device type (i.e. model name) and only downloads relevant content for the specific device. In other words, if you’re using an iPad Mini 1 (which does not have a retina display but rather a 1x resolution), then only your 1x files (more on this in a moment) will be downloaded. The assets for more powerful and sharper iPads (such as the iPad Mini 3 or 4) will not be available for download). Because the user needs only download the content that targets his/her specific device, this speeds up the download process and saves space on the device.
While this might sound complex at first, we will dive into the specifics. Luckily, Xcode and the App Store handle the majority of this work, making our lives as developers easier. As such, there won’t be much code in this tutorial but rather a deep focus on understanding the app thinning process and the the technologies which make it a reality.
There are three main aspects of App Thinning: App Slicing, Bitcode, and On Demand Resources. In this tutorial, we’ll explore each one of these.
App Slicing
The first aspect of App Thinning we will discuss is slicing. According to Apple,
“Slicing is the process of creating and delivering variants of the app bundle for different target devices.
A variant contains only the executable architecture and resources that are needed for the target device.” In other words, App Slicing delivers only relevant assets to each device (depending on screen resolution, architecture, etc.) In fact, app slicing handles the majority of the app thinning process.
When you’re ready to submit the app, you upload the .IPA or .App file to iTunes Connect, as you typically would (but must use Xcode 7 as it contains the iOS 9 SDK with support for app thinning). The App Store then slices the app, creating specific variants that are distributed to each device depending on its capabilities.
On Demand Resources
To fully comprehend and app thinning, it is imperative that you also understand On Demand Resources (ODR). On demand resources are files that can be downloaded after the app’s first installation. For example, specific levels of a game (and these levels’ associated content) could be downloaded only when the player has unlocked them. Further, earlier levels that the player has not engaged with after a certain set time can be removed to save storage on the device.
Enabling on demand resources involves changing the “Enable On Demand Resources” boolean to “Yes” in Xcode settings (under Build Settings).
Bitcode
The third and final aspect of App Thinning is bitcode. Bitcode is somewhat abstract, but in essence, it is Apple’s new way of optimizing apps before they’re downloaded. Bitcode makes apps as fast and efficient as possible on whatever device they’re running. Bitcode automatically compiles the app for the most recent compiler and optimizes it for specific architectures (i.e. arm64 for 64 bit processors such as the iPhone 6s and iPad Air 2).
Bitcode makes downloads smaller by eliminating optimizations that are made for different architectures and rather downloads only the relevant optimizations and works hand in hand with the above mentioned app thinning technologies.
Bitcode is a newer feature to iOS, and needs to be turned on for newer projects. This can be done via the the project settings under Build Settings and selecting bitcode to YES.




0 comments:
Post a Comment