Chapter 4: Viewing while Building with SwiftUI Preview
Developing an application requires several interactions between clients and developers. For example, clients may sometimes request minor changes such as colors, fonts, and image positioning. Previously, developers would need to update their designs in Xcode and recompile all the code before viewing changes. SwiftUI solves this problem by introducing canvas previews. Previews allow for live viewing of UI changes without recompiling code.
In this chapter, we will learn how to make effective use of Xcode previews to speed up the UI development time. This chapter includes the following recipes:
- Previewing a layout in dark mode
- Previewing a layout at different dynamic type sizes
- Previewing a layout in a NavigationView
- Previewing a layout on different devices
- Using previews in UIKit
- Using mock data for previews