Cash App Nick Entin Jan 23, 2020

Improving Animations on iOS with Stagehand

Article Summary

Cash App just open-sourced Stagehand, their solution to a problem that's plagued iOS developers since 2008: building animations shouldn't feel like archaeology.

Nick Entin from Cash App traces the messy evolution of iOS animation APIs (from CoreAnimation's stringly-typed key paths to UIKit blocks) and introduces their modern Swift framework that finally brings compile-time safety and composability to animation development.

Key Takeaways

Critical Insight

Cash App's Stagehand framework brings modern Swift patterns to iOS animations with compile-time safety, composability, and visual snapshot testing built in.

The demo app shows how Cash App uses this internally for screen transitions, and the testing approach could change how teams prevent animation regressions.

About This Article

Problem

iOS animation APIs haven't changed much since iOS 4.0. Developers end up picking between UIKit's block-based approach and CoreAnimation's stringly-typed key paths. These two don't work well together when you need complex animations.

Solution

Nick Entin's team at Cash App built Stagehand with Swift generics and protocol conformance. It lets you animate any type, not just views and layers. Type safety comes from key path-based keyframe definitions.

Impact

Stagehand uses snapshot testing to generate animated GIFs of entire animations. This catches animation regressions by letting you visually verify how animations behave when code changes.