Skip to content

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.

CodeNameMeaningCommon cause
0successCommand completed.Happy path.
1unexpectedUnexpected error.Bug. Please file an issue.
2invalidNameInvalid name argument.Name isn’t a valid Swift identifier or doesn’t match the case convention.
3directoryExistsTarget directory already exists.swiftspawn new against an existing folder; pass --force to overwrite.
4insufficientDiskSpaceNot enough disk space to scaffold.Free up space and retry.
5notInProjectNot inside a swiftspawn project.No .swiftspawn.yml walking up from cwd; cd into a project first.
6prerequisiteMissingA required tool is missing.swift, xcode-select, swiftlint, or swiftformat not on PATH.
7routeMarkersMissingRoute.swift is missing the auto-generated markers.Markers were deleted; restore them per Markers.
9fileNotFoundA --from file path does not exist.Typo in the path, or the file moved.
10urlFetchFailedA --from URL failed to fetch.Network issue, DNS, or server returned non-2xx.
11malformedJSONA --from JSON sample is invalid.The file isn’t valid JSON, or the URL returned non-JSON.
12routeDuplicateA route case with that name already exists.Picked a name that conflicts; pick another.
13templateMissingA bundled Stencil template is missing from the binary.Build/install issue with the CLI itself. Reinstall.
14xcodeprojNotFoundswiftspawn open couldn’t find an .xcodeproj.Project was created with --no-xcodeproj, or the file was deleted.
15malformedSpecAn OpenAPI spec is malformed.YAML/JSON syntax error or the spec isn’t OpenAPI 3.0+.
16packageMarkersMissingPackage.swift is missing the auto-managed markers.Markers were deleted; restore them per Markers.
#!/usr/bin/env bash
swiftspawn generate screen MovieList on Movies --uses MovieService
case $? 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 ;;
esac

The canonical list lives in Sources/SwiftspawnKit/Errors/SwiftspawnError.swift.