What is a maintainable way to model navigation in a growing SwiftUI app?

Move beyond demo-level stacks and discuss route modeling, feature boundaries, and testability

Answer

What usually breaks first

Navigation becomes fragile when route state is spread across unrelated views as booleans, optionals, and incidental side effects. A maintainable answer consolidates navigation into explicit domain state.

Better modeling pattern

  • Define routes as enums or typed path state.
  • Keep parent features responsible for child navigation decisions when possible.
  • Design with deep links and restoration in mind rather than bolting them on later.

Example

swift
enum Route: Hashable {
    case question(String)
    case bookmarks
    case settings
}

What interviewers are listening for

They want to hear how your navigation model affects feature ownership, testability, and the ability to evolve the app without scattering routing logic everywhere.