scaffold_view
Generate a new SwiftUI view file with a struct conforming to View, a body property, and an optional #Preview block. This tool creates a well-structured starting point for any SwiftUI view, saving you from writing boilerplate code by hand.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | — | The name of the view (e.g., "ProfileHeader" generates ProfileHeaderView.swift) |
outputPath | string | Yes | — | Absolute path to the directory where the file will be created |
includePreview | boolean | No | true | Whether to include a #Preview block at the bottom of the file |
Usage Examples
Section titled “Usage Examples”Create a basic view with preview
Section titled “Create a basic view with preview”“Create a new SwiftUI view called ProfileHeader in my Views folder”
{ "name": "ProfileHeader", "outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Views"}Create a view without preview
Section titled “Create a view without preview”“Scaffold a SettingsRow view without a preview provider”
{ "name": "SettingsRow", "outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Views/Settings", "includePreview": false}Create a reusable component view
Section titled “Create a reusable component view”“Generate a SwiftUI view called ActivityRingChart for my components”
{ "name": "ActivityRingChart", "outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Components"}Example Output
Section titled “Example Output”Created view file: /Users/dev/Projects/FitnessTracker/FitnessTracker/Views/ProfileHeaderView.swift
File contents: import SwiftUI
struct ProfileHeaderView: View { var body: some View { Text("ProfileHeader") } }
#Preview { ProfileHeaderView() }Related Tools
Section titled “Related Tools”scaffold_viewmodel— Create a matching view model for this viewproject_create— Create a full project if you have not started one yetscaffold_widget— Scaffold a widget extension with its own view hierarchy