Free preview lesson
Meet SwiftUI and Your First View
Create a SwiftUI project and open the preview
Why this matters: every screen you build in this course starts with a project. Xcode is Apple's app-building tool, and a project is the folder that holds all the files for one app. Choosing the SwiftUI interface tells Xcode to set up your app with SwiftUI, Apple's modern toolkit for describing screens in code.
Follow these steps:
- Open Xcode and choose Create New Project.
- Pick the App template under iOS and click Next.
- Give your project a name, pick SwiftUI for the Interface option, and choose Swift for the language.
- Save the project somewhere easy to find.
- In the left panel, open ContentView.swift. This is the file that holds your first screen.
- Turn on the canvas if it is hidden, using the Editor menu or the canvas toggle, then click Resume so the preview runs.
The canvas preview is a live picture of your screen. It is a fast way to see changes without running the full app. As you type, it updates after a short pause. If it shows an error, read the message in the Issue navigator and fix the line it points to.
What to do now: create your project, open ContentView.swift, and confirm the preview shows a default screen with a globe icon and Hello, world text.