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

  1. Create a new project

    Open Xcode. On the Welcome window choose Create New Project (or menu File → New → Project…).

  2. Pick the App template

    Make sure the iOS tab is selected at the top, choose App, and click Next.

  3. 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.

  4. 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.

  5. 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.

  6. 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!

[ Screenshot placeholder — "Hello, world!" running in the iPhone Simulator ]

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:

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:

  1. Create a project from the App template.
  2. Describe your UI in SwiftUI's body.
  3. Preview changes live in the Canvas.
  4. 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.