Enter code in an app playground in Swift Playgrounds on Mac
You can enter or edit code in an app playground by clicking in the coding area and typing. As you type, suggestions for completing your code appear. To accept a suggestion, press Return.
You can also add code by inserting Swift files, Swift packages, images, and more in the left sidebar. To see these items in an app playground, click at the top left. See Add Swift files, images, and more to an app playground.
You can add SwiftUI controls, views, symbols, colors, and more from the built-in libraries by clicking the icons in the toolbar above the coding area.
Note: If your screen space is limited (for example, if you’re working in multiple windows in Split View), the icons shown below may be replaced by .
Click to open the Views Library.
Click to open the Modifiers Library.
Click to open the Symbols Library.
Click to open the Colors Library.
Tip: You can customize the toolbar. Control-click in the toolbar, then choose whether to display the items in the toolbar as text, icons, or both. You can also choose Customize Toolbar to add or remove items.
Enter code
In an app playground you create, or in a sample app playground from the App Gallery, you can enter code.
In the Swift Playgrounds app on your Mac, open an app playground you created, or open a sample app from the App Gallery in the More Playgrounds window.
To go to the More Playgrounds window, choose Window > My Playgrounds, then click See All near the bottom right.
Click in the app’s coding area and enter code.
Note: If you don’t want to change existing code, you can add a Swift file and enter code in it.
If code completion suggestions appear as you type, you can accept them by pressing Return.
See the Swift Playgrounds developer document to learn about writing code for app playgrounds, using sample code, and creating and sharing learning experiences in Swift Playgrounds.
Search across your project files
While you’re entering code, you can search for text across all the files in your app playground to find places where you might want to make changes.
In the app playground you’re creating, open the left sidebar (if it’s not already open) by clicking at the top left.
In the search field at the top of the left sidebar, enter the text you want to find, then press Return.