Using previews in UIKit
Xcode previews provide a fast and easy way to quickly preview the current state of your view. Previews were introduced in Xcode 11 together with SwiftUI. You might think previews can only be used on SwiftUI apps, but you'll be wrong. UIKit apps can also make use of this great new feature!
In this recipe, we will set up a UIKit view to make it "previewable" in the Xcode canvas.
Getting ready
If you have not yet done so, download the GitHub repository for this book from https://github.com/PacktPublishing/SwiftUI-Cookbook.
How to do it…
We will change the build settings of UIKit to add iOS 13+ capabilities to the debug build, and then set up the UIKit page to preview our code during design and debugging. The steps are as follows:
- Open the initial iOS 12 XCode project located at https://github.com/PacktPublishing/SwiftUI-Cookbook/tree/master/Chapter03%20-%20Viewing%20while%20building%20with%20SwiftUI%20Preview/05%20...