Expedia Kari Grooms Apr 8, 2021

Lessons in SwiftUI

Article Summary

Kari Grooms from Vrbo's iOS team discovered SwiftUI wasn't just a learning curve—it was a complete rethink of how to build mobile UIs. Her team's migration revealed surprising gotchas that most tutorials won't tell you.

When Vrbo (part of Expedia Group) decided to adopt SwiftUI after WWDC 2020, they expected modern declarative UI benefits. What they got was a masterclass in framework limitations, testing challenges, and the messy reality of UIKit/SwiftUI coexistence in production apps.

Key Takeaways

Critical Insight

SwiftUI delivers massive code reduction but requires careful architecture decisions around testing, iOS version support, and strategic UIKit interoperability for production apps.

The article reveals a clever ButtonViewModel pattern that solves SwiftUI's biggest testing weakness—and it's simpler than you'd think.

About This Article

Problem

Kari Grooms' team ran into a wall with SwiftUI. It was missing key components that UIKit had, like UISearchController and UIImagePickerController. So even after iOS 14 added LazyVStack and LazyHStack, they had to keep using UICollectionViews.

Solution

Vrbo built a ButtonViewModel architecture that pulled view logic out of SwiftUI Views. This let them unit test button configuration, styling, and state management without needing to create actual SwiftUI components.

Impact

The team cut down their button code significantly while handling four button styles, multiple sizes, inverse variants, icon modes, and dark mode support. All of it was testable through the ViewModel without poking around inside the views.