TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Using modern SwiftUI NavigationStack with UINavigationController

Forums > SwiftUI

As part of dropping support for iOS15, I'm trying to move our app to use the newer navigation architecture for some of its SwiftUI views. However, these views are shown in the context of the main part of the app being written in UIKit. So, when the SwiftUI view is pushed on the nav stack, it needs to interact with the existing UINavigationController, even when navigating to additional SwiftUI-based screens.

This works with the simple NavigationLink that takes both a destination view and a label. However, now that the init(isActive:destination:label:) initializer is deprecated, trying to move to the value-based NavigationLink/navigationDestination functions for some more of our data-driven navigations just doesn't work.

Here's a link to a repo with a sample app demonstrating the problem: https://github.com/lj-dickey/UIKitNav

I'm wondering if there is any way of working around this with a purely SwiftUI solution? Otherwise, if we want to get rid of the deprecation warnings, we'll need to kick back to UKIt to manage SwiftUI -> SwiftUI navigation, which seems particularly unfortunate.

Thanks for any advice!

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.