Your first SwiftUI screen
5 minInstall Xcode, open your first SwiftUI project, and rebuild Airbnb's Start your search bar while the canvas redraws beside your code. Then put it on your iPhone and see where Claude fits.
Lesson video
Tastebud · 5:00 · Captions on screen
A SwiftUI view describes what to show, and Xcode's canvas redraws it each time you change a line.
- Why. You describe the screen and SwiftUI works out the drawing, so the canvas can show a change without running the whole app on a phone.
- Real example. Airbnb's Explore tab opens with a white Start your search pill. Rebuilt in SwiftUI, it's one Label and five modifier lines, and the canvas shows each one. (Airbnb, Nov 2026)
- When to break it. Without a Mac, Swift Playground on an iPad builds SwiftUI apps for free and can submit one to the App Store. Move to Xcode when the project outgrows it.
- Common mistake. Keeping the canvas closed and pressing Run after every change. Each Run rebuilds and relaunches the app, while the canvas updates only the view you're editing.
Our take. Type your first SwiftUI screen by hand before you ask Claude in Xcode for anything. The short view you wrote yourself is what lets you read the long one an agent writes next.
Get Xcode and your first project running
Xcode 27.2 is free on the Mac App Store and needs a Mac with an M1 chip or later, on macOS Tahoe 26.6 or later. The first hour runs from an empty Mac to the app on your own iPhone.
Your first hour in Xcode goes from an empty Mac to the app on your iPhone
- Check the Mac. It needs an M1 chip or later and macOS Tahoe 26.6 or later.
- Install Xcode and sign in. Xcode 27.2 is free on the Mac App Store. Sign in under Settings > Apple Accounts.
- Choose App from New Project. In the Welcome to Xcode window, then save the project.
- Open ContentView.swift, Show Canvas. The canvas works as soon as the project exists, so you can design before you ever run.
- Run on an iPhone simulator. Pick a simulator as the run destination and click Run to see the whole app.
- Run on your own iPhone. Pair it in Device Hub, turn on Developer Mode, and pick your personal team at Set Up Signing. The US$99 Developer Program comes later, for TestFlight and the App Store.
Bring in Claude once you can read the code
Xcode's coding assistant runs Claude Agent or ChatGPT inside the app. Claude Code can also work on the same project from Terminal, through a connection Xcode provides. Either way, read each change before you keep it.
- Xcode > Settings > Intelligence, then Get next to the agent
- Open the coding assistant with Command-0
- Changes show as change bars you can roll back
- ChatGPT works even without an account
- Claude Code, on a Pro plan or above
- In Intelligence settings, let external agents use Xcode Tools
- Connect with claude mcp add --transport stdio xcode -- xcrun mcpbridge
- Open the project in Xcode before you prompt
Both read and change the same files, so check every change in the canvas before you keep it.
Try it
Build Airbnb's search bar line by line
Turn each modifier line on and off and watch the preview. With all five on, you have the Start your search bar from Airbnb's Explore tab.
- Label("Start your search", systemImage: "magnifyingglass")
Each line wraps everything above it, so the last line is the outside layer.
What to notice: Turn on .frame and the bar stretches across the screen, 44 points tall. On a white screen .background shows nothing until .shadow traces the pill's edge, and .padding then pulls the pill 16 points in from each side.
Quick check
Your canvas shows the search bar, but the white pill hugs the text instead of spanning the screen. Which line is missing?
Watch next
Watch it for Installing Xcode 27, the main areas of the window, the SwiftUI canvas and a first run in the iPhone Simulator.
Watch it for Setting up Claude in Xcode 27, planning before prompting, and reviewing the layouts it generates.
Connects to: 14.1 iPhone vs Android · 6.1 Thinking in components · 16.1 Your first Compose screen · 17.1 React Native and Expo
Sources · checked Nov 2026
- Xcode on the Mac App StoreXcode 27.2 (29 Oct 2026) is free and requires macOS 26.6 or later and a Mac with an Apple M1 chip or later; it includes Swift 6.4 and the iOS 27.2 SDK
- Apple Developer: Creating an Xcode project for an appChoose App from the New Project menu in the Welcome to Xcode window, then File > Save Project; the main window has a toolbar, navigator, editor, canvas, inspector and debug area
- Apple Developer: Adding previews to your interface filesThe #Preview macro tells the canvas what to show; Show Canvas sits in the upper-right corner of the toolbar
- Apple Developer: Running your app on simulated or physical devicesSimulators run in Device Hub; Manage Devices opens Device Hub to pair a device; sign in under Xcode > Settings > Apple Accounts with a personal Apple Account or a Developer Program account, then Set Up Signing with your team
- Apple Developer: Managing your simulated and physical devices in Device HubChoose Manage Devices from the run destination menu; connect the iPhone by cable, tap Trust, and pair it in Device Hub
- Apple Developer: Enabling Developer Mode on a deviceDeveloper Mode appears once pairing starts; turn it on under Privacy & Security, restart, then tap Enable and enter the passcode
- Apple Developer: Setting up coding intelligenceXcode > Settings > Intelligence turns on agents such as Claude Agent; ChatGPT in Xcode works with or without an account
- Apple Developer: Writing code with intelligence in XcodeThe coding assistant opens with Command-0; changes show as change bars in the editor and can be rolled back
- Apple Developer: Giving external agents access to XcodeSet Allow External Agents to Use Xcode Tools in Intelligence settings, connect Claude Code with claude mcp add --transport stdio xcode -- xcrun mcpbridge, check with claude mcp list, and open the project in Xcode before you prompt
- Apple Human Interface Guidelines: ButtonsA button needs a hit region of at least 44x44 pt
- Swift Playground on the App StoreSwift Playground 4.7 is free, builds SwiftUI apps on iPad and can submit them to the App Store with App Store Connect
- Apple Developer Program: EnrolThe Apple Developer Program costs US$99 a year
- Airbnb on the App Store (screenshots)The Explore screen: Start your search, then All, Homes, Experiences and Services, then View trip details and Recently viewed
- Claude Code docs: Set upClaude Code needs a Pro, Max, Ultra, Team, Enterprise or Console account; the free claude.ai plan doesn't include it