Integrating SwiftUI into UIKit Apps
  • Books
  • Downloads
  • Table of contents
  • Introduction
  • 1.SwiftUI essentials
  • 1.1Views and scenes
  • 1.2State and view updates
  • 1.3Data management
  • 1.4Environment
  • 1.5View modifiers
  • 1.6Layout
  • 1.7Accessibility
  • 1.8Previews in Xcode
  • 2.SwiftUI in a separate view controller
  • 2.1Presenting UIHostingController programmatically
  • 2.2Setting up Hosting Controller in storyboards
  • 2.3Subclassing UIHostingController
  • 3.SwiftUI in an embedded view
  • 3.1Programmatically embedding a SwiftUI view
  • 3.2Adding a SwiftUI view in storyboards
  • 4.SwiftUI in collection view cells
  • 4.1Creating custom cells using UIHostingConfiguration
  • 4.2Styling collection cells in SwiftUI
  • 4.3Managing cell interactions
  • 5.SwiftUI in widgets
  • 5.1Setting up a widget extension
  • 5.2Supporting multiple widget sizes
  • 5.3Adding Lock Screen widgets
  • 6.Advanced SwiftUI integration
  • 6.1Passing values to SwiftUI with UITraits
  • 6.2Using SwiftUI animations to animate UIKit views
  • 7.UIKit in SwiftUI
  • 7.1Migrating from UIKit to the SwiftUI app lifecycle
  • 7.2Embedding a UIView into SwiftUI
  • 7.3Wrapping a UIViewController into a SwiftUI view

Previews in Xcode

In this subchapter, you'll learn how to use Xcode previews to instantly visualize SwiftUI views, configure preview devices and settings, and explore multiple view variations using preview variants.

You need to purchase the book to read this chapter.WWDC 2025 offer is active now: 30% off!Learn more about the bookAlready have a copy? Request access.
Nil CoalescingAboutBlog
© 2025 NIL COALESCING LIMITED