title: How to navigate back to UIViewController from SwiftUI View?
body: <p>I'm using SwiftUI 1.0 in all my views starting from MainView which is the Home screen other than the Login as I'm using a client LoginSDK which is made via UIKit.</p>
  <p>So in LoginViewController, I'm able to push the MainView() on sucessful login with code below:</p>
  <pre><code>func showMainView() {
      let host = UIHostingController(rootView: MainView())
      self.navigationController?.navigationBar.isHidden = true
      self.navigationController?.pushViewController(host, animated: true)
  }
  </code></pre>
  <p>In the MainView, I have tried implementing a logout method that sets the LoginViewController as the rootView when the user clicks the logout Button with the code below:</p>
  <pre><code>struct MainView: View {
      
      var body: some View {
              NavigationView {
                      VStack {
                          Button(action: {
                             logout()
                          }, label: {
                              Image(&quot;Logout&quot;)
                                  .resizable()
                                  .frame(width: 20, height: 16)
                          })
                      }
              }
      }
  
    //Method to logout and set the RootNavigationViewController as rootViewController
    func logout () {
      let storyboard = UIStoryboard(name: &quot;Main&quot;, bundle: nil)
      //The LoginViewController is embedded in RootNavigationViewController
      let rootViewController = storyboard.instantiateViewController(withIdentifier: &quot;RootNavigationViewController&quot;) as! UINavigationController
              
      if let window = UIApplication.shared.windows.first {
          window.rootViewController = rootViewController
          window.endEditing(true)
          window.makeKeyAndVisible()
      }
    }
  
  }
  </code></pre>
  <p>The above logout method implementation is doing nothing. I would like to know how can I navigate back to LoginViewController (A UIKit UIViewController) from MainView (A SwiftUI struct).</p>