Xcode's coding agents let developers and designers rapidly generate multiple SwiftUI UI variations from natural-language prompts, each rendered as a named Xcode Preview tab, enabling fast design exploration without leaving the IDE.
⢠Agents generate real, native SwiftUI code you can carry forward into production ā not throwaway mockups
⢠Requesting multiple named preview variations in a single prompt lets you evaluate divergent design directions side-by-side in seconds
⢠Combining agents with Xcode Previews creates a tight iterate-preview loop for animations, edge cases, and real content without a full build cycle
Shows how to structure a SwiftUI file with multiple named PreviewProvider entries ā mirroring what Xcode's coding agent produces when you ask for several design variations ā so each appears as its own canvas tab.
import SwiftUI
// MARK: - Sample Data (keep in its own file for reuse across prototypes)
struct BookClubSampleData {
static let currentBook = "The Remains of the Day"
static let members = ["Alice", "Ben", "Clara", "Dan", "Eva"]
static let nextMeeting = "Thursday, 7 PM Ā· Blue Bottle Coffee"
static let readingProgress: Double = 0.62
}
// MARK: - Shared Sub-views
struct ProgressRacetrack: View {
var progress: Double
var body: some View {
GeometryReader { geo in
ZStack(alignment: .leading) {
Capsule().fill(Color.secondary.opacity(0.2))
Capsule()
.fill(Color.accentColor)
.frame(width: geo.size.width * progress)
}
}
.frame(height: 10)
}
}
// MARK: - Variation 1: Cozy
struct BookClubCozyView: View {
var body: some View {
NavigationStack {
VStack(alignment: .leading, spacing: 20) {
Text(BookClubSampleData.currentBook)
.font(.system(.title2, design: .serif, weight: .bold))
Text(BookClubSampleData.nextMeeting)
.font(.subheadline)
.foregroundStyle(.secondary)
ProgressRacetrack(progress: BookClubSampleData.readingProgress)
Spacer()
}
.padding()
.navigationTitle("Cozy Club")
}
}
}
// MARK: - Variation 2: Editorial
struct BookClubEditorialView: View {
var body: some View {
NavigationStack {
List {
Section("Now Reading") {
HStack {
RoundedRectangle(cornerRadius: 6)
.fill(Color.brown.opacity(0.3))
.frame(width: 50, height: 70)
VStack(alignment: .leading) {
Text(BookClubSampleData.currentBook)
.font(.headline)
Text("\(Int(BookClubSampleData.readingProgress * 100))% complete")
.font(.caption)
.foregroundStyle(.secondary)
}
}
}
Section("Standings") {
ForEach(Array(BookClubSampleData.members.enumerated()), id: \.offset) { i, name in
Label("\(i + 1). \(name)", systemImage: i == 0 ? "trophy.fill" : "person")
}
}
}
.navigationTitle("Editorial")
}
}
}
// MARK: - Previews (each gets its own canvas tab ā mirrors agent output)
#Preview("Cozy") {
BookClubCozyView()
}
#Preview("Editorial") {
BookClubEditorialView()
}
#Preview("Empty State") {
NavigationStack {
ContentUnavailableView(
"No Club Yet",
systemImage: "books.vertical",
description: Text("Create or join a book club to get started.")
)
.navigationTitle("Book Club")
}
}Agents can anchor you on an arbitrary first result ā always prompt for multiple variations upfront. Sample content and preview data should be kept in a dedicated, reusable file. Agents cannot replace design judgment; treat output as a collaborator's proposal, not a final answer. Animation constants (spring stiffness, damping) still benefit from manual tuning in previews.
Coding agents require an internet connection and Apple Intelligence-compatible hardware (M-series Mac or A17 Pro+ iPhone for on-device model steps); preview rendering runs locally.
More iOS 27 APIs land every week.
Get notified when new capabilities are published ā no noise, just signal.