Swiftpack.co - urushiyama/YUPreviewDevice.framework as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by urushiyama.
urushiyama/YUPreviewDevice.framework v1.0.6
[WIP] Add pre-defined preview devices for SwiftUI.
⭐️ 0
🕓 2 years ago
.package(url: "https://github.com/urushiyama/YUPreviewDevice.framework.git", from: "v1.0.6")

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
Last commit: 2 years ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v1.0.6
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics