Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extension on PreviewDevice that includes all available devices
import SwiftUI
/// Static properties for all preview devices.
///
/// Usage:
///
/// ```swift
/// struct TestView_Previews: PreviewProvider {
/// static var previews: some View {
/// Group {
/// TestView()
/// .previewDevice(.iPhone13ProMax)
/// }
/// }
/// }
/// ```
extension PreviewDevice {
static let iPhone4s: PreviewDevice = "iPhone 4s"
static let iPhone5: PreviewDevice = "iPhone 5"
static let iPhone5s: PreviewDevice = "iPhone 5s"
static let iPhone6Plus: PreviewDevice = "iPhone 6 Plus"
static let iPhone6: PreviewDevice = "iPhone 6"
static let iPhone6s: PreviewDevice = "iPhone 6s"
static let iPhone6sPlus: PreviewDevice = "iPhone 6s Plus"
static let iPhoneSE: PreviewDevice = "iPhone SE (1st generation)"
static let iPhone7: PreviewDevice = "iPhone 7"
static let iPhone7Plus: PreviewDevice = "iPhone 7 Plus"
static let iPhone8: PreviewDevice = "iPhone 8"
static let iPhone8Plus: PreviewDevice = "iPhone 8 Plus"
static let iPhoneX: PreviewDevice = "iPhone X"
static let iPhoneXs: PreviewDevice = "iPhone Xs"
static let iPhoneXsMax: PreviewDevice = "iPhone Xs Max"
static let iPhoneXʀ: PreviewDevice = "iPhone Xʀ"
static let iPhone11: PreviewDevice = "iPhone 11"
static let iPhone11Pro: PreviewDevice = "iPhone 11 Pro"
static let iPhone11ProMax: PreviewDevice = "iPhone 11 Pro Max"
static let iPhoneSE2: PreviewDevice = "iPhone SE (2nd generation)"
static let iPhone12mini: PreviewDevice = "iPhone 12 mini"
static let iPhone12: PreviewDevice = "iPhone 12"
static let iPhone12Pro: PreviewDevice = "iPhone 12 Pro"
static let iPhone12ProMax: PreviewDevice = "iPhone 12 Pro Max"
static let iPhone13Pro: PreviewDevice = "iPhone 13 Pro"
static let iPhone13ProMax: PreviewDevice = "iPhone 13 Pro Max"
static let iPhone13mini: PreviewDevice = "iPhone 13 mini"
static let iPhone13: PreviewDevice = "iPhone 13"
static let iPodTouch7: PreviewDevice = "iPod touch (7th generation)"
static let iPad2: PreviewDevice = "iPad 2"
static let iPadRetina: PreviewDevice = "iPad Retina"
static let iPadAir: PreviewDevice = "iPad Air"
static let iPadMini2: PreviewDevice = "iPad mini 2"
static let iPadMini3: PreviewDevice = "iPad mini 3"
static let iPadMini4: PreviewDevice = "iPad mini 4"
static let iPadAir2: PreviewDevice = "iPad Air 2"
static let iPadPro97: PreviewDevice = "iPad Pro (9.7-inch)"
static let iPadPro129: PreviewDevice = "iPad Pro (12.9-inch) (1st generation)"
static let iPad5: PreviewDevice = "iPad (5th generation)"
static let iPadPro1292ndGen: PreviewDevice = "iPad Pro (12.9-inch) (2nd generation)"
static let iPadPro105: PreviewDevice = "iPad Pro (10.5-inch)"
static let iPad6: PreviewDevice = "iPad (6th generation)"
static let iPad7: PreviewDevice = "iPad (7th generation)"
static let iPadPro111stGen: PreviewDevice = "iPad Pro (11-inch) (1st generation)"
static let iPadPro1293rdGen: PreviewDevice = "iPad Pro (12.9-inch) (3rd generation)"
static let iPadPro112ndGen: PreviewDevice = "iPad Pro (11-inch) (2nd generation)"
static let iPadPro1294thGen: PreviewDevice = "iPad Pro (12.9-inch) (4th generation)"
static let iPadMini5: PreviewDevice = "iPad mini (5th generation)"
static let iPadAir3: PreviewDevice = "iPad Air (3rd generation)"
static let iPad8: PreviewDevice = "iPad (8th generation)"
static let iPad9: PreviewDevice = "iPad (9th generation)"
static let iPadAir4: PreviewDevice = "iPad Air (4th generation)"
static let iPadPro113rdGen: PreviewDevice = "iPad Pro (11-inch) (3rd generation)"
static let iPadPro1295thGen: PreviewDevice = "iPad Pro (12.9-inch) (5th generation)"
static let iPadMini6: PreviewDevice = "iPad mini (6th generation)"
static let appleTV: PreviewDevice = "Apple TV"
static let appleTV4K: PreviewDevice = "Apple TV 4K"
static let appleTV4K1080p: PreviewDevice = "Apple TV 4K (at 1080p)"
static let appleTV4K2: PreviewDevice = "Apple TV 4K (2nd generation)"
static let appleTV4K21080p: PreviewDevice = "Apple TV 4K (at 1080p) (2nd generation)"
static let appleWatch38mm: PreviewDevice = "Apple Watch - 38mm"
static let appleWatch42mm: PreviewDevice = "Apple Watch - 42mm"
static let appleWatchSeries238mm: PreviewDevice = "Apple Watch Series 2 - 38mm"
static let appleWatchSeries242mm: PreviewDevice = "Apple Watch Series 2 - 42mm"
static let appleWatchSeries338mm: PreviewDevice = "Apple Watch Series 3 - 38mm"
static let appleWatchSeries342mm: PreviewDevice = "Apple Watch Series 3 - 42mm"
static let appleWatchSeries440mm: PreviewDevice = "Apple Watch Series 4 - 40mm"
static let appleWatchSeries444mm: PreviewDevice = "Apple Watch Series 4 - 44mm"
static let appleWatchSeries540mm: PreviewDevice = "Apple Watch Series 5 - 40mm"
static let appleWatchSeries544mm: PreviewDevice = "Apple Watch Series 5 - 44mm"
static let appleWatchSE40mm: PreviewDevice = "Apple Watch SE - 40mm"
static let appleWatchSE44mm: PreviewDevice = "Apple Watch SE - 44mm"
static let appleWatchSeries640mm: PreviewDevice = "Apple Watch Series 6 - 40mm"
static let appleWatchSeries644mm: PreviewDevice = "Apple Watch Series 6 - 44mm"
static let appleWatchSeries741mm: PreviewDevice = "Apple Watch Series 7 - 41mm"
static let appleWatchSeries745mm: PreviewDevice = "Apple Watch Series 7 - 45mm"
static let mac: PreviewDevice = "Mac"
static let macCatalyst: PreviewDevice = "Mac Catalyst"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment