Skip to content

Instantly share code, notes, and snippets.

@paulweichhart
Created December 8, 2019 20:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulweichhart/2af8be747500b12add67dd4f6e16ffbd to your computer and use it in GitHub Desktop.
Save paulweichhart/2af8be747500b12add67dd4f6e16ffbd to your computer and use it in GitHub Desktop.
SwiftUI Playground Template
import Foundation
import PlaygroundSupport
import SwiftUI
struct Content: View {
var body: some View {
Text("👋🏻, 🌍!")
}
}
PlaygroundPage.current.liveView = UIHostingController(rootView: Content())
@paulweichhart
Copy link
Author

Foundation isn't needed to get the Playground running — the import is just for convenience!
In Xcode 11.2.1 using setLiveView() wasn't working for me while using the UIHostingController did

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment