Bumble Bohdan Orlov Dec 19, 2017

Screen Navigation in iOS

Article Summary

Bohdan Orlov tackles one of iOS development's messiest problems: screen navigation that's actually testable and maintainable. Most apps get this wrong from day one.

This deep dive walks through iOS navigation patterns from basic UIViewController presentations to sophisticated coordinator architectures. Orlov progressively adds abstraction layers to decouple screens and make navigation logic unit testable, addressing real-world challenges like deep links and push notifications.

Key Takeaways

Critical Insight

Moving from coupled UIViewController presentations to testable, protocol-based navigation requires strategic abstraction layers that balance flexibility with architectural complexity.

The article reveals a graph-based algorithm for handling deep links that's far more scalable than the naive sequential approach most teams use.

About This Article

Problem

iOS view controllers often have tight coupling that makes navigation logic hard to unit test. OCMock and swizzling are common workarounds, but they don't work well with pure Swift classes.

Solution

Bohdan Orlov's team used presenter and view controller factory closures injected through protocols like ViewControllerPresenting. This let them create mock implementations for isolated unit testing without modifying UIViewController internals.

Impact

Developers can now verify navigation decisions in unit tests by checking what arguments were passed to mock presenters. This catches bugs like string identifier typos in storyboards and XIBs before they cause runtime crashes.