Adding SwiftUI to an existing app
In this recipe, we will learn how to navigate from a UIKit view to a SwiftUI view while passing a text as argument from our UIKit storyboard to our SwiftUI view.
A storyboard is a visual representation of the user interface in UIKit. The Main.storyboard
file is to UIKit as the ContentView.swift
file is to SwiftUI. They both are the default home views created when you start a new project.
The recipe begins with a UIKit project that contains a button.
Getting ready
To prepare for this recipe, perform the following steps:
- Clone or download the GitHub project at https://github.com/PacktPublishing/SwiftUI-Cookbook.
- Open the
StartingPoint
folder located atSwiftUI-Cookbook/Chapter01 - Using the basic SwiftUI Views and Controls/10 - Adding SwiftUI to UIKit
and double-click on theAddSwiftUIToUIKitApp.xcodeproj
file. It opens up the UIKit project in Xcode.
How to do it…
We will add a NavigationController
to the UIKit...