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?
- Easily preview Mermaid diagrams
- Live update when editing in your preferred editor
- Capture screenshots with customizable margins
- Create PNG from the Terminal
- Free download on the Mac App Store
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.
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:
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
- Watch app
- third-party Frameworks and Swift libraries
- 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:
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:
The app contains 9 localizations:
Interestingly the localizations take 33MB which is quite a lot. The French localization contains the following files:
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
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:
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.
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:
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:
|Asynchronous socket networking library
|iOS Network Layer
|Bluetooth device communication?
|Set of iOS controls
|Google Toolbox for Mac
|Generic gRPC client
|Google Toolbox for Mac - Session Fetcher
|Phone number handling library
|iOS library to natively render After Effects vector animations
|Protocol Buffers with small code size
|A network time protocol (NTP) client
|Crashlytics, Google Analytics
|UI controls and gestures in Swift
|Address, postal code, country
|Seems to only export a no-op nlmagma_noop() function
|Core Data model
|Use Broker, StoreMad and CoreData
|UI controls and UIKit categories
|Mostly Foundation Categories
|Weather model and UI
|Work With Nest products?
|Protocol Buffers - Google’s data interchange format
|RPC library for Protocol Buffers
|Drop in replacement for Apple Reachability
|Asynchronous image downloader with cache support as a UIImageView category
|Salesforce SDK (real-time chat with agents)
|Salesforce SDK (display Knowledge articles)
|Audio compression format designed for speech
|Core Data Utilities
|Thermostat model and UI
|Camera video frame decoder
|Device Manager and Bluetooth communication
|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
The Watch app takes around 23 MB. Let’s zoom into it:
The Watch app contains Swift code and as such the Swift libraries are copied:
Note that for such a small app, the Swift libraries take 30% of the size!
The frameworks used by the Watch app are with no surprise a subset of the frameworks used in the iOS app:
The Watch app contains 10 localizations:
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.
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:
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:
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:
|Extend Apple’s NSOperation API
|Firebase iOS SDK
|Analytics, databases, messaging and crash reporting
|Google Analytics Services SDK
|Shared utility methods
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:
- 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?)
While analyzing the app, I discovered several points worth mentionning:
The unused small
HillviewToMiranda.gpx file contains GPS information representing a route between
Nest Labs Miranda. The route can be visualized using http://www.gpsvisualizer.com:
The app contains the small
thief.jpg image which appears to be unused:
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:
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, …).