Airbnb Tyler Hedrick Aug 11, 2020

Lottie and Swift at Airbnb

Article Summary

Airbnb rewrote their massively popular Lottie animation library from scratch in Swift. Here's why they chose a complete rewrite over incremental updates.

Tyler Hedrick from Airbnb's iOS team shares the personal and technical journey behind migrating Lottie, the open-source animation library used by over 50% of top apps, from Objective-C to Swift. Written in 2019, this reflects a pivotal moment in iOS development.

Key Takeaways

Critical Insight

Airbnb chose a full Swift rewrite to future-proof Lottie, reduce technical debt, and make the codebase accessible to modern iOS developers.

The author went from actively avoiding Swift to championing the rewrite after a frustrating debugging session revealed the true cost of legacy code.

About This Article

Problem

Tyler Hedrick found a bug in Lottie where animation layers weren't hiding correctly based on button state. The problem was that the codebase was written in Objective-C across many layers, with contributions from different engineers who had their own coding styles.

Solution

Airbnb worked with Brandon Withrow to rewrite Lottie in Swift. Swift's structs, pattern matching, and protocol-oriented programming made the code cleaner and easier to maintain, so modern iOS engineers could contribute without as much friction.

Impact

Once Airbnb integrated the new Swift version into their app, Tyler could debug issues directly and fix them himself. He also added Objective-C compatibility support. The rewrite made it easier for engineers across the community to improve the library.