Exit codes
Every exit code swiftspawn can return, and what each one means.
swiftspawn exits 0 on success. Any non-zero code maps to a specific error class. Use these in scripts to handle failures explicitly instead of grepping stderr.
| Code | Name | Meaning | Common cause |
|---|---|---|---|
| 0 | success | Command completed. | Happy path. |
| 1 | unexpected | Unexpected error. | Bug. Please file an issue. |
| 2 | invalidName | Invalid name argument. | Name isn’t a valid Swift identifier or doesn’t match the case convention. |
| 3 | directoryExists | Target directory already exists. | swiftspawn new against an existing folder; pass --force to overwrite. |
| 4 | insufficientDiskSpace | Not enough disk space to scaffold. | Free up space and retry. |
| 5 | notInProject | Not inside a swiftspawn project. | No .swiftspawn.yml walking up from cwd; cd into a project first. |
| 6 | prerequisiteMissing | A required tool is missing. | swift, xcode-select, swiftlint, or swiftformat not on PATH. |
| 7 | routeMarkersMissing | Route.swift is missing the auto-generated markers. | Markers were deleted; restore them per Markers. |
| 9 | fileNotFound | A --from file path does not exist. | Typo in the path, or the file moved. |
| 10 | urlFetchFailed | A --from URL failed to fetch. | Network issue, DNS, or server returned non-2xx. |
| 11 | malformedJSON | A --from JSON sample is invalid. | The file isn’t valid JSON, or the URL returned non-JSON. |
| 12 | routeDuplicate | A route case with that name already exists. | Picked a name that conflicts; pick another. |
| 13 | templateMissing | A bundled Stencil template is missing from the binary. | Build/install issue with the CLI itself. Reinstall. |
| 14 | xcodeprojNotFound | swiftspawn open couldn’t find an .xcodeproj. | Project was created with --no-xcodeproj, or the file was deleted. |
| 15 | malformedSpec | An OpenAPI spec is malformed. | YAML/JSON syntax error or the spec isn’t OpenAPI 3.0+. |
| 16 | packageMarkersMissing | Package.swift is missing the auto-managed markers. | Markers were deleted; restore them per Markers. |
Using exit codes in scripts
Section titled “Using exit codes in scripts”#!/usr/bin/env bashswiftspawn generate screen MovieList on Movies --uses MovieServicecase $? in 0) echo "ok" ;; 5) echo "not in a project; cd into one first" ; exit 5 ;; 7) echo "Route.swift markers gone; please restore" ; exit 7 ;; 12) echo "movieList already exists; skipping" ;; *) echo "unexpected failure" ; exit 1 ;;esacSource
Section titled “Source”The canonical list lives in Sources/SwiftspawnKit/Errors/SwiftspawnError.swift.