Enter code in an app playground in Swift Playgrounds on iPad
You can enter or edit code in an app playground by tapping in the coding area and typing. As you type, suggestions for completing your code appear. To accept a suggestion, tap it.
You can also add Swift files, Swift packages, and more in your app playgrounds. To see these items in an app playground, tap 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 tapping 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 .
Tap to add a view from the Views Library.
Tap to add a modifier from the Modifiers Library.
Tap to add a symbol from the Symbols Library.
Tap to add colors from the Colors Library.
Tip: You can customize the toolbar by adding or removing items. Tap , then choose Customize Toolbar.
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 iPad, open an app playground you created, or open a sample app playground from the App Gallery on the More Playgrounds screen.
Tap in the app playground’s coding area and start typing.
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 tapping them.
To turn off the line numbers to the left of your code, tap , then choose Hide Line Numbers.
(Line numbers appear in the coding area by default.)
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 tapping at the top left.
In the search field at the top of the sidebar, enter the text you want to find, then tap the Search key on the keyboard (or press Return).