Translations Available

YUPreviewDevice.framework

Add pre-defined preview devices for SwiftUI.

YUPreviewDevice.framework adds pre-defined preview devices for SwiftUI.

SwiftUI is the one of elegant ways for building native UI. However, its preview is totally messy. To show preview on a specific device, you need to exactly type a specific name such as “iPhone Xʀ”, “iPad Pro (12.9-inch) (2nd generation)” or “Apple Watch Series 4 - 40mm” in View.previewDevice(_:). How can we remember the exact name?

YUPreviewDevice.framework adds pre-defined preview devices for SwiftUI. Using this framework, you can easily preview your app on a specific device:

struct YourSwiftUIView_Previews: PreviewProvider {
  static var previews: some View {
    YourSwiftUIView()
      .previewDevice(PreviewDevice.iPhone_11_Pro_Max)
      .previewDisplayName(PreviewDevice.iPhone_11_Pro_Max.rawValue)
  }
}

You can also easily preview your app on multiple iOS devices with different ratio:

struct YourSwiftUIView_Previews: PreviewProvider {
  static var previews: some View {
    ForEach(PreviewDevice.Product.latest_iOS_devices_with_defferent_ratio) { device in
      YourSwiftUIView()
        .previewDevice(PreviewDevice(rawValue: device.name))
        .previewDisplayName(device.name)
    }
  }
}

License

This framework is published under MIT License. For further info, please see the repository.

© 2018-2021 urushiyama | Powered by Hugo with HUCORE theme.

Privacy Policy  |  LICENSE