Lately, many people have wondered why some iOS apps were so huge. I asked myself this question and analyzed the Facebook application for iOS v. 66.0 in 2016 and v. 87.0 in 2017.

In this article, I dissect the Nest app (5.30.5) for iOS released on 29.11.2018. There has been quite some speculations about this app in a thread started by John Gruber on Twitter:

This post will answer some simple questions about this specific app:

Which technologies are used?

Why is the app so big?

Would it be possible to reduce the app size?

Note that this analysis is done purely on the technical level. I don't own a Nest product, and haven't played much with the app.

App overview

When downloading the app on an iPad Air 2, the App Store indicates a size of 206MB. On the device itself, the uncompressed application weights around 202MB which is consistent. Please note that in this article, the sizes mentioned are indicative and have been rounded in some cases. They could also vary depending on the type of iOS device.

While the application appears with the name Nest on the device, it is actually called Jasper as we can see in the Info.plist:

<key>CFBundleName</key> <string>Nest</string> <key>CFBundleExecutable</key> <string>Jasper</string> <key>CFBundleIdentifier</key> <string>com.nestlabs.jasper.release</string> <key>CFBundleVersion</key> <string>5.30.5.8</string>

Let start by looking at an overhaul overview using GrandPerspective:

The structure is well-defined and we can identify 6 parts composing the app:

main binary Jasper

Watch app

third-party Frameworks and Swift libraries

localizations

assets from the asset catalog

some extra assets, mostly composed of mp4 and wav files

We will check each of these components in the reversed order.

Extra assets (mp4, wav)

Let's start with the extra assets, mostly composed of mp4 and wav files. The application contains 46 mp4 movies to help the user set up devices. These animations probably improve the initial user experience and it makes sense to have them in the app. Here is a screenshot of one of the animation:

Assets

The compiled Asset Catalog contains 1787 assets for 31MB. Uncompressed, these assets weight 56MB. If you are interested by the .car file format, you can read my article Reverse engineering the .car file format (compiled Asset Catalogs). It is important to note that App Slicing works as expected: the compiled Assets.car on an iPad Air 2 only contains images with the @2x resolution. The images with the @1x and @3x resolutions are not present. This explains why you will see a 206MB download for an iPad Air 2 while the download on an iPhone Xs with @3x resolution is 245MB.

It is easy to extract and look at the images using my QLCARFiles QuickLook plugin:

There are quite a lot of assets but this is not unusal. However we can see that there are some big images, each taking several hundred of kilobytes:

Here is a screenshot showing the 5 biggest images, some looking like stock photos:

Localizations

The app contains 9 localizations:

de

en-GB

en

es-MX

es

fr-CA

fr

it

nl

Interestingly the localizations take 33MB which is quite a lot. The French localization contains the following files:

Each Localizable.strings file weights only around 1MB. But each localization contains localized images. Below is one example to exhibit the differences between English and French:

While this technic is perfectly valid to improve the user experience, there are some improvements that could be done. First there are several duplicated images across the localizations. As we have seen in the example above, some images are only localized to display a temperature in Fahrenheit (US) or Celsius (all other localizations). Since Fahrenheit is only used for the en localization, each of these images is duplicated 8 times, for each localization other than en :

pairing_onyx_scene.jpg pairing_onyx_scene@2x.jpg pairing_onyx_scene@3x.jpg setting_add_device_onyx_find_key_diagram_1_phone.png setting_add_device_onyx_find_key_diagram_1_phone@2x.png setting_add_device_onyx_find_key_diagram_1_phone@3x.png

An attentive reader might have spotted a second optimization: since the images are not stored in the Asset Catalog, App Slicing doesn't take effect. You will note that the images are available in the @1x, @2x and @3x resolutions although my device will only load the @2x resolutions. In order to get App Slicing working, the localized images should be stored in the asset catalog. This could be done for example by adding a suffix to the filenames and loading the images programmatically:

setting_add_device_onyx_find_key_diagram_1_phone_de.png setting_add_device_onyx_find_key_diagram_1_phone_de@2x.png setting_add_device_onyx_find_key_diagram_1_phone_de@3x.png setting_add_device_onyx_find_key_diagram_1_phone_en.png setting_add_device_onyx_find_key_diagram_1_phone_en@2x.png setting_add_device_onyx_find_key_diagram_1_phone_en@3x.png setting_add_device_onyx_find_key_diagram_1_phone_fr.png setting_add_device_onyx_find_key_diagram_1_phone_fr@2x.png setting_add_device_onyx_find_key_diagram_1_phone_fr@3x.png ...

If I remove all the duplicated images and the unneeded resolutions, the localizations would take 14MB instead of 33MB on an iPad Air 2. So we could save around 19MB here, maybe a bit more since the images would be compressed in the Assets.car.

Frameworks

The application contains 67MB of Frameworks. Let's look at them.

First there are the Swift libraries required due to the lack of ABI stability in Swift. The app is indeed written in Objective-C and Swift. The Swift libraries represent 12MB:

libswiftAVFoundation.dylib libswiftCore.dylib libswiftCoreAudio.dylib libswiftCoreData.dylib libswiftCoreFoundation.dylib libswiftCoreGraphics.dylib libswiftCoreImage.dylib libswiftCoreLocation.dylib libswiftCoreMedia.dylib libswiftDarwin.dylib libswiftDispatch.dylib libswiftFoundation.dylib libswiftMapKit.dylib libswiftMetal.dylib libswiftObjectiveC.dylib libswiftos.dylib libswiftPhotos.dylib libswiftQuartzCore.dylib libswiftsimd.dylib libswiftUIKit.dylib

Then there are a bunch of other frameworks, some developed by Nest Labs, some by third-party developers. This seems to indicate that the application is well-structured. Here is the list of the Frameworks and their utility:

Framework Size URL Description Broker 100 kB Nest Labs JSON, CoreData? CocoaAsyncSocket 500 kB https://github.com/robbiehanson/CocoaAsyncSocket Asynchronous socket networking library CocoaLumberjack 300 kB https://github.com/CocoaLumberjack/CocoaLumberjack Logging framework Courier 100 kB https://github.com/Drewsmits/Courier iOS Network Layer DCAPIService 1 MB Nest Labs Bluetooth device communication? DCKit 400 kB https://github.com/agordeev/DCKit Set of iOS controls GoogleToolboxForMac 100 kB https://github.com/google/google-toolbox-for-mac Google Toolbox for Mac grpc 2 MB https://github.com/grpc/grpc RPC library GRPCClient 500 kB https://github.com/grpc/grpc/tree/master/src/objective-c/GRPCClient Generic gRPC client GTMSessionFetcher 400 kB https://github.com/google/gtm-session-fetcher Google Toolbox for Mac - Session Fetcher libPhoneNumber_iOS 400 kB https://github.com/iziz/libPhoneNumber-iOS Phone number handling library Lottie 600 kB https://github.com/airbnb/lottie-ios iOS library to natively render After Effects vector animations Mantle 200 kB https://github.com/Mantle/Mantle Model framework nanopb 100 kB https://github.com/nanopb/nanopb Protocol Buffers with small code size NestClientProtos 100 kB Nest Labs Protobuf subclasses NexusVideoPlayer 1 MB Nest Labs Video player NHNetworkTime 100 kB https://github.com/huynguyencong/NHNetworkTime A network time protocol (NTP) client NLAnalytics 1 MB Nest Labs Crashlytics, Google Analytics NLCommonLogging 100 kB Nest Labs Logging utilities NLContentComposer 700 kB Nest Labs UI controls and gestures in Swift NLLego 1 MB Nest Labs UI controls NLLocale 200 kB Nest Labs Address, postal code, country NLMagma 100 kB Nest Labs Seems to only export a no-op nlmagma_noop() function NLModelCore 8 MB Nest Labs Core Data model NLNetwork 100 kB Nest Labs NSURLSession utilities NLStore 100 kB Nest Labs Use Broker, StoreMad and CoreData NLUI 3 MB Nest Labs UI controls and UIKit categories NLUtils 700 kB Nest Labs Mostly Foundation Categories NLWeather 5 MB Nest Labs Weather model and UI NLWWNCatalog 100 kB Nest Labs Work With Nest products? openssl/BoringSSL? 2 MB https://www.openssl.org Cryptography library Opus-ios 400 kB https://github.com/chrisballinger/Opus-iOS Audio codec PhoenixCommonProtobuf 200 kB https://developers.google.com/protocol-buffers/ Protobuf related PhoenixCore 200 kB Nest Labs Protobuf related PhoenixModels 9 MB Nest Labs Protobuf related PhoenixModelsProtobuf 2 MB Nest Labs Protobuf related PhoenixServices 400 kB Nest Labs Protobuf related PhoenixServicesProtobuf 400 kB Nest Labs Protobuf related Protobuf 1 MB https://github.com/protocolbuffers/protobuf Protocol Buffers - Google's data interchange format ProtoRPC 100 kB https://github.com/grpc/grpc/tree/master/src/objective-c/ProtoRPC RPC library for Protocol Buffers Reachability 100 kB https://github.com/tonymillion/Reachability Drop in replacement for Apple Reachability RxLibrary 100 kB https://github.com/grpc/grpc/tree/master/src/objective-c/RxLibrary Reactive Extensions SDWebImage 400 kB https://github.com/SDWebImage/SDWebImage Asynchronous image downloader with cache support as a UIImageView category ServiceChat 1 MB https://github.com/forcedotcom/ServiceSDK-iOS Salesforce SDK (real-time chat with agents) ServiceCore 3 MB https://github.com/forcedotcom/ServiceSDK-iOS Salesforce SDK ServiceKnowledge 2 MB https://github.com/forcedotcom/ServiceSDK-iOS Salesforce SDK (display Knowledge articles) speex 300 kB https://www.speex.org Audio compression format designed for speech StoreMad 100 kB https://github.com/Drewsmits/StoreMad Core Data Utilities StructureViewModel 200 kB Nest Labs Devices status ThermostatViewModel 300 kB Nest Labs Thermostat model and UI ThumbnailEngine 300 kB Nest Labs Camera video frame decoder Weave 4 MB Nest Labs Device Manager and Bluetooth communication youtube_ios_player_helper 100 kB https://github.com/youtube/youtube-ios-player-helper YouTube video playback

That's quite a lot of frameworks. I don't know if they are all needed but some seem to overlap:

Speex has been obsoleted by Opus

There are 3 networking libraries: CocoaAsyncSocket, Courier, NLNetwork

There are multiple Protocol Buffers related frameworks

Watch app

The Watch app takes around 23 MB. Let's zoom into it:

Swift libraries

The Watch app contains Swift code and as such the Swift libraries are copied:

libswiftCore libswiftCoreFoundation libswiftCoreGraphics libswiftDarwin libswiftDispatch libswiftFoundation libswiftObjectiveC libswiftUIKit

Note that for such a small app, the Swift libraries take 30% of the size!

Other Frameworks

The frameworks used by the Watch app are with no surprise a subset of the frameworks used in the iOS app:

Broker CocoaLumberjack Courier Mantle NLAnalytics NLCommonLogging NLMagma NLModelCore NLNetwork NLStore NLUI NLUtils StoreMad StructureViewModel ThermostatViewModel

Localizations

The Watch app contains 10 localizations:

de

en-GB

en

es-MX

es

fr-CA

fr

it

nl

vi

I wondered why the Watch app would contain one extra language, especially Vietnamese… Opening and reading the localization gave the answer:

If you pay attention, you will note that the text is written in English with special characters. So this is most likely a fake localization used for testing which ended up in the release app by accident. Removing this localization would save around 1.3 MB.

Jasper binary

The main binary Jasper is 22MB. The entropy graph generated by Hopper indicates that most of the content is likely code (higher entropy and visible as red):

There is no surprise when listing the libraries loaded by the binary:

@rpath/Broker.framework/Broker @rpath/CocoaAsyncSocket.framework/CocoaAsyncSocket @rpath/CocoaLumberjack.framework/CocoaLumberjack @rpath/Courier.framework/Courier @rpath/DCAPIService.framework/DCAPIService @rpath/DCKit.framework/DCKit @rpath/GoogleToolboxForMac.framework/GoogleToolboxForMac @rpath/grpc.framework/grpc @rpath/GRPCClient.framework/GRPCClient @rpath/GTMSessionFetcher.framework/GTMSessionFetcher @rpath/libPhoneNumber_iOS.framework/libPhoneNumber_iOS @rpath/libswiftAVFoundation.dylib @rpath/libswiftCore.dylib @rpath/libswiftCoreAudio.dylib @rpath/libswiftCoreData.dylib @rpath/libswiftCoreFoundation.dylib @rpath/libswiftCoreGraphics.dylib @rpath/libswiftCoreImage.dylib @rpath/libswiftCoreLocation.dylib @rpath/libswiftCoreMedia.dylib @rpath/libswiftDarwin.dylib @rpath/libswiftDispatch.dylib @rpath/libswiftFoundation.dylib @rpath/libswiftMapKit.dylib @rpath/libswiftMetal.dylib @rpath/libswiftObjectiveC.dylib @rpath/libswiftos.dylib @rpath/libswiftPhotos.dylib @rpath/libswiftQuartzCore.dylib @rpath/libswiftsimd.dylib @rpath/libswiftUIKit.dylib @rpath/Lottie.framework/Lottie @rpath/Mantle.framework/Mantle @rpath/nanopb.framework/nanopb @rpath/NestClientProtos.framework/NestClientProtos @rpath/NexusVideoPlayer.framework/NexusVideoPlayer @rpath/NHNetworkTime.framework/NHNetworkTime @rpath/NLAnalytics.framework/NLAnalytics @rpath/NLCommonLogging.framework/NLCommonLogging @rpath/NLContentComposer.framework/NLContentComposer @rpath/NLLego.framework/NLLego @rpath/NLLocale.framework/NLLocale @rpath/NLMagma.framework/NLMagma @rpath/NLModelCore.framework/NLModelCore @rpath/NLNetwork.framework/NLNetwork @rpath/NLStore.framework/NLStore @rpath/NLUI.framework/NLUI @rpath/NLUtils.framework/NLUtils @rpath/NLWeather.framework/NLWeather @rpath/NLWWNCatalog.framework/NLWWNCatalog @rpath/openssl.framework/openssl @rpath/Opus-ios.framework/Opus-ios @rpath/PhoenixCommonProtobuf.framework/PhoenixCommonProtobuf @rpath/PhoenixCore.framework/PhoenixCore @rpath/PhoenixModels.framework/PhoenixModels @rpath/PhoenixModelsProtobuf.framework/PhoenixModelsProtobuf @rpath/PhoenixServices.framework/PhoenixServices @rpath/PhoenixServicesProtobuf.framework/PhoenixServicesProtobuf @rpath/Protobuf.framework/Protobuf @rpath/ProtoRPC.framework/ProtoRPC @rpath/Reachability.framework/Reachability @rpath/RxLibrary.framework/RxLibrary @rpath/SDWebImage.framework/SDWebImage @rpath/ServiceChat.framework/ServiceChat @rpath/ServiceCore.framework/ServiceCore @rpath/ServiceKnowledge.framework/ServiceKnowledge @rpath/speex.framework/speex @rpath/StoreMad.framework/StoreMad @rpath/StructureViewModel.framework/StructureViewModel @rpath/ThermostatViewModel.framework/ThermostatViewModel @rpath/ThumbnailEngine.framework/ThumbnailEngine @rpath/Weave.framework/Weave @rpath/youtube_ios_player_helper.framework/youtube_ios_player_helper /System/Library/Frameworks/Accelerate.framework/Accelerate /System/Library/Frameworks/AddressBookUI.framework/AddressBookUI /System/Library/Frameworks/AdSupport.framework/AdSupport /System/Library/Frameworks/AssetsLibrary.framework/AssetsLibrary /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox /System/Library/Frameworks/AVFoundation.framework/AVFoundation /System/Library/Frameworks/AVKit.framework/AVKit /System/Library/Frameworks/CFNetwork.framework/CFNetwork /System/Library/Frameworks/Contacts.framework/Contacts /System/Library/Frameworks/ContactsUI.framework/ContactsUI /System/Library/Frameworks/CoreBluetooth.framework/CoreBluetooth /System/Library/Frameworks/CoreData.framework/CoreData /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics /System/Library/Frameworks/CoreLocation.framework/CoreLocation /System/Library/Frameworks/CoreMedia.framework/CoreMedia /System/Library/Frameworks/CoreTelephony.framework/CoreTelephony /System/Library/Frameworks/CoreText.framework/CoreText /System/Library/Frameworks/CoreVideo.framework/CoreVideo /System/Library/Frameworks/Foundation.framework/Foundation /System/Library/Frameworks/ImageIO.framework/ImageIO /System/Library/Frameworks/MapKit.framework/MapKit /System/Library/Frameworks/MessageUI.framework/MessageUI /System/Library/Frameworks/OpenGLES.framework/OpenGLES /System/Library/Frameworks/Photos.framework/Photos /System/Library/Frameworks/QuartzCore.framework/QuartzCore /System/Library/Frameworks/SafariServices.framework/SafariServices /System/Library/Frameworks/Security.framework/Security /System/Library/Frameworks/StoreKit.framework/StoreKit /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration /System/Library/Frameworks/UIKit.framework/UIKit /System/Library/Frameworks/UserNotifications.framework/UserNotifications /System/Library/Frameworks/WatchConnectivity.framework/WatchConnectivity /System/Library/Frameworks/WebKit.framework/WebKit /usr/lib/libc++.1.dylib /usr/lib/libc++abi.dylib /usr/lib/libobjc.A.dylib /usr/lib/libresolv.9.dylib /usr/lib/libsqlite3.dylib /usr/lib/libSystem.B.dylib /usr/lib/libz.1.dylib

More interesting is that the binary has not been stripped and contains a lot of build artifacts. I extracted the paths with grep with the following regular expression:

grep -aor '/Users/[-\+A-Za-z0-9_/\. ]*' Jasper

And obtained 360 lines like:

/Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Alarm/Mute/Hush/NLAlarmCardSafetyHusher.m /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Alarm/Mute/NLAlarmCardMuteViewModel.m /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Alarm/Mute/View/NLAlarmCardMuteViewController.m [...] /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/CameraVideo/NLVideoPlayerView.m /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Camerazilla/Analytics/CamerazillaAnalyticsReporter.m /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Camerazilla/CamerazillaActivityThumbnailViewModel.m [...] /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/CheckMarkView.swift /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Devices/Agate/Pairing/AgateConfigWorkflowSource.swift /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Devices/Agate/Pairing/AgateHeatLinkIntroWorkFlowSource.swift /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Devices/Agate/Pairing/AgateIntroWorkflowSource.swift /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Devices/Agate/Pairing/AgateLocaleSettingViewController.swift /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/Classes/Devices/Agate/Pairing/PairingFlow+Agate.swift [...] /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/v4Classes/ViewControllers/StructureHomeAwayAssistViewController.m /Users/admin/bamboo-agents/bamboo-agent-1/xml-data/build-dir/JSP-PDB823-NESTMOBILE/Jasper/v4Classes/ViewControllers/StructureHomeAwaySummaryViewController+Tahiti.m /Users/crashlytics/buildAgent/work/7e5c596e59839c6e/apple/AnswersKit/AnswersKit/ANSBackoffTimer.m

We see that Nest uses Bamboo to build the application and we have the confirmation that the app uses Swift and Objective-C code. We can also estimate that ~45% of the files are written in Swift.

This information can also be used to rebuild the file hierarchy:

While we have a lot of details about the internal files, that does not seem to explain why the binary is 22MB. Performing a class-dump of the code will give answers to this question. The class-dump indicates that there are almost 3000 Swift and Objective-C classes.

By looking at the classes, we can identify several statically linked libraries:

Framework URL Description Answers https://fabric.io/kits/ios/answers Analytics Crashlytics crashlytics.com Crash reporting FABOperation https://github.com/google-fabric/FABOperation Extend Apple's NSOperation API Firebase iOS SDK https://firebase.google.com Analytics, databases, messaging and crash reporting Google Analytics Services SDK https://developers.google.com/analytics/devguides/collection/ios/v3/ Analytics GoogleUtilities http://cocoadocs.org/docsets/GoogleUtilities/ Shared utility methods WEPopover https://github.com/werner77/WEPopover Popover implementation

The Google Analytics Services SDK can be downloaded as a static library which weights 36 MB for 5 architectures. So most likely this SDK counts for around 7MB in the binary.

The Firebase iOS SDK seems to be quite huge too but I did not manage to estimate its size. It is also interesting to note that there are multiple (overlapping?) frameworks to track users:

Answers

Firebase iOS SDK

Google Analytics Services SDK which is according to the documentation superseeded by the Firebase iOS SDK

NLAnalytics (which might just be a wrapper?)

Miscellaneous

While analyzing the app, I discovered several points worth mentionning:

HillviewToMiranda.gpx

The unused small HillviewToMiranda.gpx file contains GPS information representing a route between Nest and Nest Labs Miranda . The route can be visualized using http://www.gpsvisualizer.com:

thief.jpg

The app contains the small thief.jpg image which appears to be unused:

SnapshotMap.json

This file contains information about Jira bugs.

Devices code name

As we can see from the NLDeckItemModel subclasses, Nest seems to like rock names for product code names:

NLDeckItemAgate NLDeckItemDiamond NLDeckItemFlintstone NLDeckItemHeatLink NLDeckItemHotWater NLDeckItemKryptonite NLDeckItemOnyx NLDeckItemPinna NLDeckItemQuartz NLDeckItemTopazes LockzillaDeckItem

Conclusion

We discovered that the app is written in Objective-C and Swift, with a non-negligeable part in Swift. The source code seems to be well-structured with reusable code in frameworks.

The frameworks are representing an important part of the app size. First the Swift libraries in the app and in the Watch app are counting for approximatively 10% of the total size. There are also a lot of other frameworks. Some could possibly overlap like the analytics frameworks: Answers, Firebase iOS SDK, Google Analytics Services SDK.

The application contains a lot of assets including mp4 animations to help the users set up their devices. These assets obviously increase the size of the app.

We also found some simple ways to reduce the app size by around 10%: use App Slicing for the localized images, remove duplicated localized images, remove fake vietnamese localization, remove unused assets (HillviewToMiranda.gpx, thief.jpg, SnapshotMap.json, …).