Unlocking SwiftUI at Airbnb

How Airbnb adopted SwiftUI in our iOS app

Bryn Bodayle
13 min readadvanced
--
View Original

Overview

The article discusses Airbnb's adoption of SwiftUI in their iOS app, detailing the motivations behind the transition from their custom framework Epoxy to SwiftUI. It highlights the benefits of SwiftUI in terms of user experience, developer efficiency, and the challenges faced during the integration process.

What You'll Learn

1

How to integrate SwiftUI into an existing iOS app

2

Why SwiftUI can improve developer efficiency and reduce code complexity

3

When to transition from UIKit to SwiftUI for better performance

Prerequisites & Requirements

  • Understanding of UIKit and Swift programming
  • Experience with iOS app development

Key Questions Answered

What were the main reasons for Airbnb's transition to SwiftUI?
Airbnb transitioned to SwiftUI to enhance both user and developer experiences. They aimed to leverage SwiftUI's declarative syntax for flexibility, reduce code complexity, and improve iteration speeds, ultimately leading to a more efficient development process.
How did Airbnb ensure a smooth adoption of SwiftUI?
Airbnb adopted SwiftUI in phases, starting with building reusable components and progressing to full screens and features. They conducted pilot programs to gather feedback and improve their SwiftUI support, ensuring gradual integration without overwhelming their existing infrastructure.
What challenges did Airbnb face while adopting SwiftUI?
Airbnb encountered several challenges, including limited visibility into SwiftUI's evolution, the need for custom navigation patterns, and issues with LazyVStack and ScrollView functionalities. These challenges necessitated bridging to UIKit for certain features and highlighted the need for more robust SwiftUI APIs.
What improvements in code efficiency were observed with SwiftUI?
Airbnb reported a significant reduction in lines of code, achieving a 6x decrease in a specific component rewrite, dropping from 1,121 lines to 174 lines. This trend continued as they adopted SwiftUI more broadly, resulting in similar reductions across their codebase.

Key Statistics & Figures

Lines of Code Reduction
6x reduction
In an early experiment, Airbnb reduced the code from 1,121 lines to 174 lines for a rewritten component.
Developer Satisfaction
77%
In a survey, 77% of Airbnb's engineers reported that SwiftUI improved their efficiency.

Technologies & Tools

Frontend
Swiftui
Used for building user interfaces in Airbnb's iOS app.
Frontend
Uikit
Previously used framework for building user interfaces before transitioning to SwiftUI.
Frontend
Epoxy
Airbnb's custom UI framework that was replaced by SwiftUI.

Key Actionable Insights

1
Adopting SwiftUI can significantly enhance developer productivity by reducing the amount of code needed to implement UI components.
As demonstrated by Airbnb's experience, transitioning to SwiftUI led to a 6x reduction in lines of code for specific components, which not only simplifies maintenance but also accelerates the development process.
2
Implementing a phased approach to adopting new frameworks like SwiftUI can mitigate risks and allow for gradual learning.
Airbnb's strategy of piloting SwiftUI components before full-scale implementation provided valuable feedback and allowed engineers to adapt to the new framework without disrupting existing workflows.
3
Investing in education and training for your engineering team can significantly boost confidence and proficiency in new technologies.
Airbnb reported a 37% increase in confidence among engineers who attended SwiftUI workshops, highlighting the importance of structured learning in successful technology adoption.

Common Pitfalls

1
Failing to properly evaluate the impact of transitioning to a new UI framework can lead to performance issues.
Airbnb's careful evaluation of SwiftUI's performance compared to UIKit helped them avoid potential pitfalls and ensure a smooth transition.
2
Neglecting to provide adequate training and resources for engineers can hinder the adoption of new technologies.
Airbnb's investment in SwiftUI workshops significantly improved their team's confidence and capability, emphasizing the need for structured learning during technology transitions.

Related Concepts

Declarative UI Frameworks
Performance Optimization In Mobile Apps
Best Practices For UI Design