Swiftpack.co - Package - urushiyama/YUPreviewDevice.framework

YUPreviewDevice

Add pre-defined preview devices for SwiftUI.

Screenshot

GitHub release (latest by date) LICENSE Platform Total Download of All Releases Twitter Follow

Install

  • [WIP] From Swift Package Manager:
  1. Select File > Swift Packages > Add Package Dependency... in Menu Bar of Xcode.
  2. Enter https://github.com/urushiyama/YUPreviewDevice in the text field and press "Next".
  3. Select versions/branches what you want to install and press "Next".
  4. Press "Finish".
  • From Self-build:
  1. Open this project's clone in Xcode.
  2. Select "YUPreviewDevice-Package" scheme.
  3. Select Product > Build in Menu Bar of Xcode.
  4. Copy Products/YUPreviewDevice.framework to the project where you want to import.

Usage

  • Show latest iOS devices with defferent ratio as SwiftUI Previews:
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)
    }
  }
}
  • Show specific preview:
struct YourSwiftUIView_Previews: PreviewProvider {
  static var previews: some View {
    YourSwiftUIView()
      .previewDevice(PreviewDevice.iPhone_11_Pro_Max)
      .previewDisplayName(PreviewDevice.iPhone_11_Pro_Max.rawValue)
  }
}

Complete list of pre-defined devices can be found here.

Author

Yuta Urushiyama

aswif10flis1ntkb [at] gmail.com

Twitter @YUrushiyama

License

MIT License

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

v1.0.6 - 2020-03-10 08:01:25

v1.0.5 - 2020-01-16 00:19:32