IDN Media Bevan Christian Jun 11, 2023

On-Demand Resources for Lottie Animation Storage in Swift

Article Summary

Bevan Christian from IDN Engineering tackles a problem every mobile team faces: beautiful Lottie animations that bloat your app size. His solution? On-Demand Resources that cut initial download size while keeping the polish.

This technical guide walks through implementing Apple's On-Demand Resources feature to host Lottie animations separately from your main app bundle. Bevan shares real implementation code for lazy-loading animations (like onboarding flows) only when needed, rather than forcing users to download them upfront.

Key Takeaways

Critical Insight

By moving rarely-used Lottie animations to On-Demand Resources, you can ship smaller app bundles without sacrificing visual polish or user experience.

The article includes a gotcha about testing that could save you hours of debugging (hint: it involves where you can actually validate initial install tags).

About This Article

Problem

When product teams add large animation files like 2 MB Lottie assets that only get used once during onboarding, the app size grows noticeably. This makes users hesitant to download because of storage concerns.

Solution

Bevan Christian used Apple's On-Demand Resources feature with NSBundleResourceRequest to load Lottie animations conditionally. The animations are hosted separately on the App Store and only download when users reach the onboarding flow.

Impact

Users get faster initial downloads and use less device storage. Developers can add animations without worrying about making the bundle larger or forcing users to re-download assets.