Use and create playground books in Swift Playgrounds on Mac
In addition to working with app playgrounds, you can use and create playground books in Swift Playgrounds. To view sample playground books, go to the More Playgrounds window—the sample playground books are in the Books section at the bottom.
Use a playground book
In the Swift Playgrounds app on your Mac, click a playground in the Books section at the bottom of the More Playgrounds window to view a description.
If you’re in the My Playgrounds window, click See All near the bottom right to go to the More Playgrounds window.
If you’re working in a playground, choose Window > My Playgrounds, then click See All near the bottom right.
Click to return to the More Playgrounds window, then click Get to download the playground book.
After it’s downloaded, double-click the playground book to open it.
If there’s code in the playground book, you can click Run My Code to see what it does.
To step through the code and see it become highlighted as it runs, click , then choose Step Through My Code (or use the Run My Code button in the Touch Bar).
Create a new playground book
To create a new playground book, go to the My Playgrounds window (choose Window > My Playgrounds or click at the top left of the More Playgrounds window, then click the Playground button near the bottom left. This creates a blank playground (named My Playground), which appears in the My Playgrounds window. You can double-click to open it.
When you’re ready to add your own code, see Enter code in a playground book. You can apply what you learned in the Learn to Code playgrounds and other playgrounds where you tried running code.