Your First App: Hello, World!
Time to build something real. In this lesson you'll create a new project, run it on a simulated iPhone, understand every line of the starter code, and make your first change. By the end you'll have a working app with your own message on screen.
Before you begin: make sure Xcode is installed and launched at least once. If not, head back to Setting up Xcode.
Step by step
-
Create a new project
Open Xcode. On the Welcome window choose Create New Project (or menu File → New → Project…).
-
Pick the App template
Make sure the iOS tab is selected at the top, choose App, and click Next.
-
Configure your app
Fill in the options:
- Product Name:
HelloWorld - Organization Identifier:
com.yourname(any reverse-domain text) - Interface: SwiftUI
- Language: Swift
Click Next, choose a folder to save it in, then Create.
- Product Name:
-
Meet the Xcode workspace
Xcode opens your project. On the left is the Navigator (your files), in the middle the Editor (your code), and on the right the Canvas — a live preview of your app.
-
Choose a simulator
At the top of the window, next to the Run button, click the device menu and pick an iPhone (e.g. iPhone 16 Pro). The Simulator is a virtual iPhone that runs on your Mac — no physical device needed.
-
Run your app
Press the ▶ Run button (or
⌘ + R). Xcode builds the app and launches the Simulator. After a moment you'll see “Hello, world!” on a simulated iPhone screen. That's your first app running!
Understanding the starter code
Open ContentView.swift in the Navigator. SwiftUI generates
something like this for a new project:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
#Preview {
ContentView()
}
ContentView.swift — the screen you saw running.
Let's break it down line by line:
import SwiftUI— brings in Apple's UI framework so you can use its tools.struct ContentView: View— defines a screen. The: Viewpart promises "this is something SwiftUI can display."var body: some View— thebodydescribes what appears on screen. Whatever you put here is your UI.VStack { ... }— a Vertical Stack: it arranges the things inside it top-to-bottom.Image(systemName: "globe")— shows a built-in system icon (the small globe)..imageScaleand.foregroundStyleare modifiers that style it.Text("Hello, world!")— displays the text label..padding()— adds breathing room around the stack.#Preview { ... }— powers the live Canvas preview on the right, so you see changes without running the full app.
Modifiers are how you style SwiftUI views. You chain
them with a dot, e.g. .padding() or .foregroundStyle(.tint).
Order matters — each modifier wraps the result of the one before it.
Make it yours
Let's change the message. Replace the Text line and add a few
modifiers:
Text("Hello, iOS! 👋")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundStyle(.blue)
A bigger, bold, blue greeting.
The Canvas preview updates instantly. Press ⌘ + R again to see
it in the Simulator. Congratulations — you just edited a live iOS app.
What just happened
You learned the core loop of iOS development:
- Create a project from the App template.
- Describe your UI in SwiftUI's
body. - Preview changes live in the Canvas.
- Run on the Simulator with
⌘ + R.
Every app you'll ever build — from a to-do list to a full social network — is this same loop, repeated and layered. You're officially an iOS developer now.
Up next: we'll start the Swift Language track — variables, constants, and the building blocks you'll use in every single app. Tell me when you're ready and I'll build it.