You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

How we reduced Naukri iOS App size by 50% using App Thinning

0.00 avg. rating (0% score) - 0 votes

With iOS 9, Apple has introduced the “App Thinning” feature which will save the device memory and downloading time for user. In previous version, developer were supposed to make universal build which includes all the assets of the devices. So, when application installed on the devices, it has all the resources regardless of the device specifications. With App Thinning, only required assets will be downloaded, that are required to run the application on the particular iOS device.

In countries like India, where majorly people doesn’t have high speed internet, have limited data or concerned regarding the data consumption. App thinning will be beneficial for application and its users because it will reduce the data consumption, reduce the time and most important reduce the memory. So we have implemented “App Thinning” in our “Naukri India” Application to focus on those people those have limited Data and memory.

There are three main aspects of App Thinning:-

  1. Assets slicing
  2. On Demand Resources
  3. Bit Code

App Slicing

According to Apple,
“Slicing is the process of creating and delivering variants of the app bundle for different target devices.”

App Slicing will provide only required assets to device (depending upon device configu- ration). Developer still have to upload the universal build (.ipa) files over the iTunes.

apple_app_slicing_illustration-516x300

Source: http://www.appcoda.com/app-thinning/

 

AppStore will slice the application according the user’s device (depending upon the de- vice configuration).

For example, User have a iPhone 6 Plus and download the application from Apple Store. Apple store will give the only iPhone 6 plus variant. So user will not get @2x assets, iPad Assets or iPhone 4s assets. So User will get smaller build and will download in less time & consume less data.

On Demand Resources

On-Demand Resources are files that are downloaded when they are needed and that are also cleared from devices when their purpose fulfilled.

ODR_flow_2x

Source: http://arstechnica.com/apple/2015/06/app-thinning-will-be-a-major-boon-for-8gb-and-16gb-iphones-and-ipads/

We can enable the On Demand Resources by changing the “Enable On Demand Re- sources” boolean to Yes under the Xcode Settings (Build Settings).

Screen Shot 2016-01-08 at 12.38.37 PM

Bitcode

Bitcode optimizes the application before the application download. It optimizes the ap- plication according to the devices configuration and architecture. Bitcode make the downloadable build smaller by eliminating unnecessary optimizations and download only relevant optimization. Using Bitcode is enabled by default but still optional for iOS apps (expect it to become required in the future, though). It is, however, required for native Apple Watch apps.

We can switch on the BitCode Feature in our project by enabling the “Enable BitCode” boolean to Yes under the Xcode Settings

Screen Shot 2016-01-08 at 12.40.17 PM

Testing with App Thinning
To implement the App Thinning, we must use the “Asset catalogs”. The Asset Catalog contains 1x, 2x, and 3x versions of the app icon and other images also. Assets Catalogs will look like:-

Screen Shot 2016-01-08 at 12.43.40 PM

First We run the application over the device, see the memory taken by application. We search “Manager Storage” under the “Setting section”. We scroll down to notice the memory.


In our case, we run the application over the iPhone 5c, memory taken by application is 21.1 MB. This time, device have fat version of the application (Build that have all resource irre- spective the device configuration). Xcode doesn’t automatically handle the app variant and app thinning.

Next, we created the build of the application by clicking on the “Archive” option in “Product” Tab. While uploading the application over iTunes Store, we have to enable the boolean “Enable BitCode” to Yes.

After uploading the build over iTunes Store, we will have our new build version in list of the build over iTunes Connect. We select the new build and send the invitation through TestFlight.

Page-4-Image-8

After the getting the invitation, we can download the new version of application over the device through TestFlight.

Page-5-Image-9

We have installed the application and visited the  “Manager Storage” and checked the application. Now its 8.8MB. This time, application have only device specific resources or relevant resources.

For iPhone 5c, App thinning saves around 12.3 MB (58%).

We ran same steps over various devices. We got following analysis data. On a average, App thinning saves 30-50% memory.

Screen Shot 2016-01-08 at 1.19.57 PM

Effect of App Thinning over Naukri India iOS App

References: –

1. Working with App Thinning in iOS 9
2. App thinning in iOS 9: Explained

Posted in Mobile