Swiftpack.co - Toni77777/PreviewDevice as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Toni77777.
Toni77777/PreviewDevice 0.9.0
PreviewDevice - is a library with type-safe syntax sugar for preview device on SwiftUI.
⭐️ 19
🕓 5 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Toni77777/PreviewDevice.git", from: "0.9.0")

PreviewDevice

Platforms Version SPM Xcode Twitter

Requirements

  • Dev environment: Xcode 13+, macOS 12+
  • iOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+

Usage

Example:

import PreviewDevice

struct ContentView_Previews: PreviewProvider {
    
    static var previews: some View {
        ContentView()
            .previewDevice(device: .iphone13, colorSchemes: ColorScheme.allCases)
    }
}

Result

Preview on device

.previewDevice(device: .iphone12)

Preview on devices

.previewDevices(device: [.iphone8, .iphone11Pro .iphone12, .iphone12ProMax])

Preview on device with color scheme (light, dark)

.previewDevice(device: .iphone12, colorScheme: .light)

Preview on device with ColorSchemes

.previewDevice(device: .iphone12, colorScheme: [.light, .dark])

Preview on device with orientation (InterfaceOrientation)

.previewDevice(device: .iphone12, orientation: .portrait)

Preview on device with orientations

.previewDevice(device: .iphone12, orientations: [.portrait, .landscapeLeft, .landscapeRight])

Preview on device with orientation and color schemes

.previewDevice(device: .iphone12, orientation: .portrait, colorSchemes: [.light, .dark])

Installation

CocoaPods

Specify next line in Podfile:

pod PreviewDevice

Swift Package Manager

Open Xcode, File -> Swift Packages -> Add Packages.. and paste library git url:

https://github.com/Toni77777/PreviewDevice.git

Articles

Meet PreviewDevice 0.7.0

What's new in PreviewDevice 0.8.0

License

PreviewDevice is released under the MIT license.

GitHub

link
Stars: 19
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Release 0.9.0
5 weeks ago

Preview for Cocoa views:

  • NSViewControllerPreview - preview for NSViewController.
  • NSViewPreview - preview for NSView.

Preview for UIKit views:

  • UIViewControllerPreview - preview for UIViewController.
  • UIViewPreview - preview for UIView.

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