- Swift 4 Programming Cookbook
- Keith Moon
- 215字
- 2025-04-04 18:15:56
How to do it...
With Xcode downloaded, let's create our first Swift playground:
- Launch Xcode from the icon in your dock.
- From the welcome screen, choose Get started with a playground:

- From the template chooser, select the blank template from the iOS tab:

- Choose a name for your playground and a location to save it:

Xcode Playgrounds can be based on one of the three different Apple platforms: iOS, tvOS, and macOS (the operating system formerly known as OSX). Playgrounds provide full access to the frameworks available to either iOS, tvOS, or macOS, depending on which you choose. An iOS playground will be assumed for the entirety of this book, chiefly because this is the platform of choice of the author. Where recipes do have UI components, the iOS platform will be used until stated otherwise.
- You are now presented with a view that looks like this:

- Let's replace the word playground with Swift!.
- Click on the blue play icon in the bottom left-hand corner of the window to execute the code in the playground:

- Congratulations! You have just run some Swift code.
- On the right-hand side of the window, you will see the output of each line of code in the playground. We can see that our line of code has output "Hello, Swift!":
