Integrating SwiftUI and UIKit Navigation: A Step-by-Step Guide
Article Summary
Bevan Christian from IDN Engineering tackles a problem every iOS team faces: how do you navigate between SwiftUI and UIKit without creating a maintenance nightmare?
Most teams use UIHostingController and UIViewControllerRepresentable to bridge SwiftUI and UIKit, but this creates inconsistent navigation patterns and tightly couples navigation logic to views. Bevan presents a router-based architecture that unifies navigation across both frameworks using UIKit's existing navigation system.
Key Takeaways
- Router pattern eliminates need for UIViewControllerRepresentable when navigating SwiftUI to UIKit
- ViewModels trigger navigation through injected routers, separating concerns cleanly
- All navigation leverages UINavigationController for consistent experience across frameworks
- Protocol-based router delegates handle push, pop, and modal presentations uniformly
A router-coordinator pattern lets you navigate seamlessly between SwiftUI and UIKit while keeping navigation logic out of views and maintaining a single, consistent navigation system.
About This Article
When legacy UIKit apps add SwiftUI, teams have to work with two different navigation systems. They need to learn both UIViewControllerRepresentable and UIHostingController, and navigation patterns end up inconsistent across modules.
Bevan Christian's approach uses router classes with delegate protocols to handle all navigation in one place. ProfileViewModel can trigger navigation actions through ProfileSwiftUIRouter, and SwiftUI views get wrapped in UIHostingController so everything routes through UINavigationController.
This router-based setup decouples views from navigation logic. You can move between SwiftUI modals, UIKit view controllers, and pushed SwiftUI views using the same navigation system throughout the app.