Mobile development

Stage 2 · Lesson 2 of 10

Xcode previews

SwiftUI views and layout

The #Preview draws a view in 's canvas as you type. You can add several for one view, to see it with a long title, empty data or in . The canvas can switch devices, orientation and size (the user's text size setting).

Live mode lets you tap and scroll. Xcode Previews work best with views that take plain data. So pass sample values instead of making a view fetch its own.

When a preview fails, the error is often in code the view depends on, so keep sample data simple.

Common traponly ever looking at the preview on the latest large iPhone, never on a small one or in dark mode.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CourseFree
    SwiftUI Tutorials (Apple)

    Apple · Beginner

    Apple's own path from views and stacks to lists and navigation

  • CourseFree
    100 Days of SwiftUI

    Paul Hudson (Hacking with Swift) · Beginner

    Days 16 to 35 build six small apps on views, modifiers, lists and animation

Practise

  • Use a free challenge's mobile design image as the spec for a native screen

Keep handy

Mark this stage as not done?