Skip to content
A Playground for running SwiftUI tutorial code on macOS Mojave
Branch: master
Clone or download
Latest commit eab2e8f Jun 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
SwiftUI.playground Re-added license Jun 12, 2019
.gitignore Initial commit Jun 10, 2019 Formatting Jun 12, 2019

SwiftUI Playground for macOS Mojave

Apple announced their new SwiftUI Framework at WWDC 2019.

While it requires macOS Catalina beta to be run natively, it can already be used in Swift Playgrounds on the current stable version, macOS Mojave.

This project provides a Playground version of Apple’s Building Lists and Navigation tutorial. Xcode 11 beta is required.


A UIHostingController can be used in a Playground Live View like this:

PlaygroundPage.current.liveView = UIHostingController(rootView: PlaygroundRootView())

The given root view must be public, along with its init() and body:

public struct PlaygroundRootView: View {
    public init() {}
    public var body: some View {

From here on, standard SwiftUI Views can be used to build the interface.


Press the blue Play button next to the PlaygroundPage.current.liveView line or type ⇧⌘↵ to run the Playground. If, after the initial build, the preview is not responsive, just press the Play button again.


Use View > Navigator > Show Project Navigator or ⌘1 to show the Playground’s source files and recources.

You can’t perform that action at this time.