iOS App Clips reduce size
Hi! In this article, I will talk about how to meet the 10 MB that are so necessary for the cherished skipping of the App Clip
file in TestFlight.
How to find out the size of the App Clip
file.
To find out the size of libraries, images, your xib/storyboard files and etc. do the following:
- Create Ad Hoc provisioning profile
- Archive your app in Xcode.
- Export your archived app as an Ad Hoc
- In the sheet for setting the development distribution options, choose “All compatible device variants” for app thinning, and enable Rebuild from Bitcode.
- Sign your app and export it to your Mac.
- Once the App Clip is uploaded to the directory you specified, you must go to it and in a file called App Thinking Size Report.txt at the very end you will find the right sizext” a
- Once the
App Clip
file is uploaded to the directory you specified, you must go to it and in a file called App Thinking Size Report.txt at the end you will find the right size.
If your size is more than 10 MB, then make from your ipa
zip
file, unzip and see what and how much weighs, for me the heaviest were the libraries.
Reduce the size of the app clip file
Frameworks.
To begin, identify which libraries are definitely not needed for you, for me it was FirebaseCrashlytics, YandexMobileMetrica, PhoneNumberKit and a few more, after removing which I reduced the App Clip by 17.2 MB and I had to reduce by another 4.5 MB to get the coveted ten megabytes. When all unnecessary libraries are removed, consider whether some of the remaining libraries can be replaced with a native offer from Swift with little loss?
For me, it turned out to be a KingFisher library, which I successfully replaced with a native implementation of image acquisition and caching and thereby reduced by another 869 kB, cuz you remember that we only make all these replacements and dances with bubbles for the screens that are needed for the App Clip
application, and not the entire application.
It is worth paying attention to another nuance, libraries that you need, but at the same time they are old version and your project allows you to update them, then it is worth trying to do this, for me several old libraries brought an additional 205 kB.
Images.
For myself, I identified all the images that I would need only for the App Clip
application and so I created a separate Assets
folder to take all the images from the main Assets
folder there and thereby out of 92 images in the end, 28 remained and the size decreased by another 2.3 MB. After that, I would recommend that you replace the png format with pdf and reduce the size without losing quality, if this does not suit you, then the application will ImageOptim or this site will help you.
Useless files.
Before
After
Inside Build Phase, delete files that are unnecessary for you, for me this number was reduced from 523 files in the main target to 304 for App Clip
target and thereby I reduced by another 311 kB file size.
Also do not forget to pay attention to localization of your application, I took everything necessary in a separate file for App Clip
application and saved 166 kB! Good luck and you will succeed (:
Links:
https://developer.apple.com/documentation/xcode/reducing_your_app_s_size
https://developer.apple.com/documentation/xcode/reducing_your_app_s_size/doing_basic_optimization_to_reduce_your_app_s_size