@@ -30,49 +30,46 @@ This will automatically:
3030
3131### Preview Modes
3232
33- #### Mode 1: Dynamic Preview Injection (Fastest - Recommended)
33+ The unified ` preview ` script auto-detects the best mode. You can also be explicit:
3434
35- For files with ` #Preview ` in an Xcode project, this injects a minimal PreviewHost target:
35+ #### Xcode Project with #Preview (Fastest)
36+
37+ Injects a minimal PreviewHost target, builds only required modules (~ 3-4 seconds):
3638
3739``` bash
38- " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview-dynamic.sh \
40+ " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview \
3941 " <path-to-file.swift>" \
4042 --project " <path.xcodeproj>" \
4143 --output /tmp/preview.png
4244```
4345
44- ** Advantages:**
45- - Builds only the required modules (3-4 seconds vs minutes)
46- - Works with static modules/libraries
47- - Automatically includes resource bundles (Tuist and standard naming)
48- - No pre-existing preview scheme required
49-
50- #### Mode 2: SPM Package
46+ #### SPM Package
5147
52- For files in Swift Package Manager packages :
48+ Auto-detected from Package.swift in parent directories :
5349
5450``` bash
55- " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview-spm.sh \
51+ " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview \
5652 " <path-to-file.swift>" \
5753 --output /tmp/preview.png
5854```
5955
60- #### Mode 3: Standalone Swift File (No Dependencies)
56+ #### Standalone Swift File (No Dependencies)
6157
6258For Swift files that only use system frameworks (SwiftUI, UIKit, Foundation):
6359
6460``` bash
65- " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview-minimal.sh \
61+ " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview \
6662 " <path-to-file.swift>" \
6763 --output /tmp/preview.png
6864```
6965
70- #### Mode 4: Capture Current Simulator
66+ #### Capture Current Simulator
7167
7268Just screenshot whatever is currently on screen:
7369
7470``` bash
75- " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/capture-simulator.sh \
71+ " ${PREVIEW_BUILD_PATH:- $HOME / XcodePreviews} " /scripts/preview \
72+ --capture \
7673 --output /tmp/preview.png
7774```
7875
@@ -96,7 +93,7 @@ Read /tmp/preview.png
9693```
9794User: /preview ~/MyApp/Modules/Components/Button.swift
9895→ Auto-detects MyApp.xcodeproj
99- → Uses preview-dynamic.sh for fast build (~3 seconds)
96+ → Injects PreviewHost target for fast build (~3 seconds)
10097→ Capture screenshot showing Button component
10198→ Analyze visual output
10299```
@@ -105,7 +102,7 @@ User: /preview ~/MyApp/Modules/Components/Button.swift
105102```
106103User: /preview ~/MyPackage/Sources/UI/Card.swift
107104→ Detects Package.swift
108- → Uses preview-spm.sh
105+ → Creates temporary Xcode project with SPM dependency
109106→ Capture screenshot
110107→ Analyze visual output
111108```
@@ -114,7 +111,7 @@ User: /preview ~/MyPackage/Sources/UI/Card.swift
114111```
115112User: /preview MyView.swift
116113→ Detects system-only imports
117- → Use preview- minimal.sh to build minimal host
114+ → Builds minimal host app
118115→ Capture screenshot
119116→ Analyze visual output
120117```
0 commit comments