WWDC19

Table of Contents

=================

Mastering Xcode Previews - Thursday

Session materials: https://developer.apple.com/videos/play/wwdc2019/233/

PreviewProvider Protocol

  # if DEBUG
  public enum SomePreviews: PreviewProvider {
    public static var previews: some View {
      Group {
        SomeView()
        .device() // Different devices to be shown in the preview
        .previewLayout(.sizeThatFits) // Just shows the specific view with the intrinsic size it gets,

        SomeView()
        .environment(|.sizeCategory, .extraLarge) // To simulate dynamic text sizes on the preview
        .previewDisplayName() // to show the selected preview option in the preview mode
      }
    }
  }
  #endif

Development Assets

Populate The Preview with Fixtures (JSON)

Create a New Preview File for an Existing View Controller

UIViewControllerRepresentable func makeUIViewController() { // load from storyboard or instantiate }

func updateUIViewController() {} ```

Image