Skip to content

generate route

Add a route case to Route.swift.

Adds a single case to Route.swift between the auto-managed markers. Useful for hand-written screens or routes that need parameters.

Terminal window
swiftspawn generate route <name> [--dry-run] [--force] [--quiet] [--verbose]

Most of the time you don’t need this directly: generate screen adds a route case for you. Use generate route when:

  • You wrote the screen by hand (not via generate screen).
  • You need a route case with associated values, like case movieDetail(id: Int). Generate the bare case here, then edit the file to add the parameter.

The case name is camelCase. Cases are kept sorted alphabetically inside the marker region.

Terminal window
swiftspawn generate route notifications
swiftspawn generate route movieDetail

After running the second one, edit Route.swift to add the parameter:

case movieDetail(id: Int)

None.

  • Adds case <name> to Route.swift between the markers, sorted alphabetically.
FlagDescription
--dry-runPreview without writing.
--forceNo-op for this command (route insertion is idempotent on duplicates only with --force).
CodeMeaning
2Invalid name (must be a valid camelCase identifier).
5Not in a swiftspawn project.
7Route.swift is missing the markers.
12Route case already exists.