Skip to content

Commit ddb784b

Browse files
committed
feat: add --write flag to sample script and update docs
Support full end-to-end testing via ./run-sample.sh --write. Update README with write mode usage and reset instructions.
1 parent 59d620f commit ddb784b

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,30 @@ make build
3939

4040
## Try it out
4141

42-
A sample project is included to test the tool end-to-end without needing a real Xcode workspace or Tuist:
42+
A sample project is included to test the tool without needing a real Xcode workspace or Tuist:
4343

4444
```bash
4545
cd SampleProject
46+
47+
# Preview the generated interface (dry run, no files written)
4648
./run-sample.sh
49+
50+
# Run the full pipeline (creates interface module, rewrites Project.swift and imports)
51+
./run-sample.sh --write
4752
```
4853

49-
This builds the tool, compiles a sample Swift module via SPM, extracts compiler arguments, and runs the tool with `--print-only` to display the generated interface.
54+
The script builds the tool, compiles a sample Swift module via SPM, extracts compiler arguments, and runs the tool. Use `--write` to execute the full pipeline, or omit it to preview with `--print-only`.
55+
56+
After running with `--write`, you'll see:
57+
- `libraries/business/UserProfileInterface/` created with `Sources/` and `TestSupport/`
58+
- `Project.swift` updated with the new interface module declaration
59+
60+
To reset the sample project after a full run:
61+
62+
```bash
63+
git checkout SampleProject/Project.swift
64+
rm -rf SampleProject/libraries/business/UserProfileInterface
65+
```
5066

5167
## Usage
5268

SampleProject/run-sample.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
66
MODULE_NAME="UserProfile"
77
PACKAGE_DIR="$SCRIPT_DIR/libraries/business/UserProfile"
88

9+
PRINT_ONLY="--print-only"
10+
if [ "${1:-}" = "--write" ]; then
11+
PRINT_ONLY=""
12+
echo "Running in WRITE mode - files will be created and modified."
13+
echo ""
14+
fi
15+
916
echo "=== Step 1: Build the generateInterface tool ==="
1017
cd "$REPO_ROOT"
1118
swift build -c debug 2>&1 | tail -1
@@ -50,7 +57,7 @@ echo "Compiler arguments written to: $ARGS_FILE"
5057
echo "$(wc -l < "$ARGS_FILE" | tr -d ' ') arguments extracted."
5158

5259
echo ""
53-
echo "=== Step 4: Run generateInterface with --print-only ==="
60+
echo "=== Step 4: Run generateInterface${PRINT_ONLY:+ (dry run)} ==="
5461

5562
# SourceKit requires the Xcode toolchain frameworks to be in the dynamic library path
5663
TOOLCHAIN_LIB="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib"
@@ -61,7 +68,7 @@ export DYLD_FRAMEWORK_PATH="$TOOLCHAIN_LIB:${DYLD_FRAMEWORK_PATH:-}"
6168
"$MODULE_NAME" \
6269
"$SCRIPT_DIR/libraries" \
6370
"$ARGS_FILE" \
64-
--print-only
71+
$PRINT_ONLY
6572

6673
# Clean up
6774
rm -f "$ARGS_FILE"

0 commit comments

Comments
 (0)