Skip to content

Instantly share code, notes, and snippets.

@ethanjdiamond
Created June 29, 2019 17:44
Show Gist options
  • Save ethanjdiamond/37debd574e669e4a648d9fbbe9c09d74 to your computer and use it in GitHub Desktop.
Save ethanjdiamond/37debd574e669e4a648d9fbbe9c09d74 to your computer and use it in GitHub Desktop.
Using Live Preview with Xcode11 and UIKit
#if DEBUG && canImport(SwiftUI)
import SwiftUI
extension SomeViewController: UIViewControllerRepresentable {
typealias UIViewControllerType = SomeViewController
func makeUIViewController(context: UIViewControllerRepresentableContext<UIViewControllerType>) -> UIViewControllerType {
return SomeViewController()
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: UIViewControllerRepresentableContext<UIViewControllerType>) {}
}
@available(iOS 13, *)
struct SomeViewController_Previews : PreviewProvider {
static var previews: some View {
SomeViewController()
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment