Use SwiftUI in a Playground

Let your imagination run wild!

Steven Curtis
3 min readNov 2, 2020
Photo by Mink Mingle on Unsplash

Playgrounds are a fantastic way of producing code, and you don’t even need a device in order to do so.

But how can you combine your love of SwiftUI with your love of Playgrounds? Read on.

Difficulty: Beginner | Easy | Normal | Challenging

Prerequisites:

Recommended: Be able to produce a “Hello, World!” Swift application (guide HERE)

Terminology

Playgrounds: A development environment that can be used to create Swift code

Swift: An open source programming language for macOS, iOS, watchOS and tvOS

Creating a Playground: On a Mac

You do need to have downloaded and installed Xcode on your machine

You can then go through the menu File > New Playground

I then choose iOS > New Playground in the following screen. By choosing iOS we get UIKit imported for us (which is great, as we need that)

--

--