Documentation

All guidesLocal execution

SwiftUI Preview

Write SwiftUI and use the native interpreter for quick feedback without confusing it with Swift compilation.

6 min read

The subset is interactive

Preview interprets a SwiftUI subset on iPad. It renders text, images, buttons, Toggle, TextField, SecureField, Slider, Stepper, stacks, grids, ScrollView, List, Form, navigation, shapes, Picker, TabView, and other controls defined by the renderer.

State and binding are part of the flow, so a simple counter or form can respond in Preview. Use that to inspect layout and interaction early.

struct ContentView: View {
  @State private var count = 0
  var body: some View {
    VStack {
      Text("Count: \(count)")
      Button("Add") { count += 1 }
    }.padding()
  }
}

Open in Playgrounds

The Swift Playground template creates a .swiftpm package. The app can prepare that package for Swift Playgrounds, where Apple’s tool performs full compilation and execution.

The swift terminal command explains the separation: there is no Swift compiler inside the iPad shell. Use Odete Preview for the quick loop and Playgrounds or a Mac to confirm the real app.

Read placeholders as diagnostics

A construction unknown to the parser or renderer becomes a placeholder and produces a diagnostic in Problems. That is a warning that the preview does not represent that part of the application.

Do not rely on SourceKit, full Swift autocomplete, GeometryReader, or Canvas in this Preview. Keep a minimal view for the local loop and validate APIs, packages, and compilation elsewhere.