Skip to content

Instantly share code, notes, and snippets.

View v-i-s-h-a-l's full-sized avatar
👨‍💻

v-i-s-h-a-l v-i-s-h-a-l

👨‍💻
View GitHub Profile
@v-i-s-h-a-l
v-i-s-h-a-l / SwiftUIPreviewDevice
Last active February 17, 2021 18:33
In SwiftUI with "hot reloading" a view can be previewed alongside editing code. The preview device(s) can be controlled by providing the device name in the PreviewProvider confirming struct. This is the list of all the device names.
/// Source: https://developer.apple.com/documentation/swiftui/securefield/3289399-previewdevice#discussion
/// The above document lacks updates (at the time of writing this code)
/// Some additional devices have been added in this lis
// Please, feel free to fork/comment/contribute:
// https://gist.github.com/v-i-s-h-a-l/ffd070a79125766ef4add19bb5b247cd
/// 7th revision: with suggestion from @jayrhynas (twitter)
import SwiftUI