Skip to main content

CLI reference

The complete surface of the sweetpad command-line tool: every command, the global flags, the configuration files, destination specifiers, and exit codes. For a guided tour, start with Get started with the CLI or the overview.

Commands follow a resource-then-action grammar — sweetpad scheme list, sweetpad simulator boot — and the everyday actions have top-level shortcuts (sweetpad build, sweetpad test, sweetpad run). --help works on every command and shows the options this page doesn't repeat.

Commands

Everyday

CommandWhat it does
sweetpad runBuild, install, launch, and follow logs — the flagship loop. Press r to rebuild.
sweetpad buildCompile the resolved scheme. --watch rebuilds on every Swift save; --clean first cleans.
sweetpad testRun the tests. Supports --only-testing, --skip-testing, --failed, --retry-flaky, --coverage, --junit, --watch.
sweetpad cleanClean build artifacts; --purge also deletes DerivedData.
sweetpad archiveArchive and export an .ipa (--export-method, --output).
sweetpad formatFormat Swift sources (--check to verify only; --tool swiftlint to lint). Alias: fmt.
sweetpad devicesList everything runnable — macOS, simulators, connected devices — most-used first.
sweetpad statusShow the effective build context and where each value comes from.
sweetpad doctorDiagnose the local Xcode/Swift toolchain.

Project inspection

CommandWhat it does
sweetpad project infoShow targets, configurations, and schemes.
sweetpad project newScaffold a minimal SwiftUI app (see options).
sweetpad scheme listList the schemes SweetPad found.
sweetpad settings showShow resolved build settings. --key NAME prints one bare value for scripts.
sweetpad dependency listList SPM dependencies and their locked versions. Alias: dep.
sweetpad dependency addAdd a package by URL and link a product to a target.
sweetpad dependency removeRemove a package, or unlink one product from one target.
sweetpad dependency updateUpdate resolved versions, or change a requirement.
sweetpad dependency resolveResolve dependencies into the lockfile.

App lifecycle

sweetpad run is shorthand for sweetpad app run; the rest of the lifecycle lives under app:

CommandWhat it does
sweetpad app installBuild and install without launching.
sweetpad app launchLaunch an already-installed app.
sweetpad app debugBuild, install, launch suspended, and attach lldb (simulator).
sweetpad app logsStream the running app's logs.
sweetpad app stopTerminate the running app.
sweetpad app uninstallRemove the app from a simulator or device.
sweetpad app open-urlOpen a URL on a simulator — deep links and universal links.

Simulators

Alias: sim. Most take an optional target (name or UDID) and default to the booted simulator.

CommandWhat it does
sweetpad simulator listList available simulators.
sweetpad simulator bootBoot a simulator (prompts when omitted; --wait blocks until ready).
sweetpad simulator shutdownShut down a simulator.
sweetpad simulator openOpen the Simulator.app window.
sweetpad simulator screenshotSave a PNG (--clipboard copies instead).
sweetpad simulator recordRecord the screen to an mp4 — Ctrl-C stops and finalizes.
sweetpad simulator appearanceSwitch light/dark appearance.
sweetpad simulator status-barSet a clean status bar for screenshots (9:41, full bars); --clear resets.
sweetpad simulator locationSet the simulated GPS location.
sweetpad simulator pushDeliver an APNs push payload from a JSON file.
sweetpad simulator privacyGrant, revoke, or reset a privacy permission for an app.
sweetpad simulator media-addAdd photos and videos to the media library.
sweetpad simulator createCreate a new simulator.
sweetpad simulator cloneClone a shut-down simulator under a new name.
sweetpad simulator eraseErase contents and settings (simulator must be shut down).
sweetpad simulator deleteDelete a simulator — no undo (--yes skips the prompt).

Context and configuration

CommandWhat it does
sweetpad context showShow the remembered scheme, configuration, and destination.
sweetpad context selectChange a remembered value interactively (--testing for the test context).
sweetpad context setSet a value without prompting — script- and CI-friendly.
sweetpad context removeClear one remembered value, or --all for the whole context.
sweetpad context aliasName a destination (context alias work-phone <UDID>), then use --on work-phone anywhere.
sweetpad open <what>Open the project in xcode, the sim window, the dd (DerivedData) folder, or your config file.

Maintenance and integration

CommandWhat it does
sweetpad derived-data pathPrint this project's DerivedData folder (--all for the whole store). Alias: dd.
sweetpad derived-data sizeReport DerivedData's on-disk size.
sweetpad derived-data purgeDelete DerivedData (--yes skips the prompt).
sweetpad merge installRegister git merge drivers that resolve .pbxproj and Package.resolved conflicts semantically (--global for all repos).
sweetpad merge runResolve conflicted project files in the current merge by hand.
sweetpad bsp initWrite buildServer.json so SourceKit-LSP autocomplete works in any editor.
sweetpad bsp doctorCheck the autocomplete wiring.
sweetpad completions <shell>Generate completions for bash, zsh, fish, elvish, or PowerShell.
sweetpad self-updateUpdate sweetpad (Homebrew installs run brew upgrade instead).
sweetpad help [topic]Built-in guides: config, environment, exit-codes, destinations, hot-reload.
sweetpad vscode <method>Drive a running VSCode window — see Agent CLI & RPC server.

Global flags

These work on every command:

FlagWhat it does
-C <dir>Run as if started in that folder, like git -C.
-o, --output <mode>Output mode: human (default), json, ndjson, or quiet.
--jsonShorthand for -o json.
--non-interactiveNever prompt — missing choices become errors. Auto-enabled when CI is set.
--gh-annotationsEmit GitHub Actions annotations for build/test errors. Not combinable with -o json/ndjson.
--developer-dir <dir>Pin the Xcode to use (same as the DEVELOPER_DIR environment variable).
--no-colorDisable colored output (also honors NO_COLOR).
-v, --verboseShow raw tool output.
-q, --quietSuppress progress chatter (wins over --verbose).

Commands that build or run also take targeting flags: --workspace, --project, --scheme, --configuration, --sdk, and the two ways to say where — --destination (a raw specifier) or --on (a human-friendly reference; the two are mutually exclusive).

Environment variables

Every targeting flag has an environment-variable twin, so CI pipelines can set the context once: SWEETPAD_WORKSPACE, SWEETPAD_PROJECT, SWEETPAD_SCHEME, SWEETPAD_CONFIGURATION, SWEETPAD_DESTINATION, SWEETPAD_ON, and SWEETPAD_SDK. SWEETPAD_NONINTERACTIVE=1 (or CI=1) turns prompts into errors. NO_COLOR and CLICOLOR_FORCE control color. Run sweetpad help environment for the full story.

Configuration files

Three layers, from personal to shared:

  • ~/.config/sweetpad/config.toml — your personal defaults. A [defaults] table for global values, plus [projects."<path to .xcodeproj/.xcworkspace/Package.swift>"] tables for per-project overrides. SweetPad never writes this file; it's yours.
  • sweetpad.toml next to the project — team defaults, meant to be committed. Same keys (scheme, configuration, destination, sdk), plus developer_dir and [run], [format], and [testing] tables.
  • Remembered state — the answers you gave to interactive prompts, stored per project. Inspect and change it with sweetpad context, not by editing files.

When the same value is set in several places, the most explicit one wins:

flag > environment variable > config.toml > sweetpad.toml > remembered answer > auto-detect

Typos are never silently ignored — unknown keys produce a warning on every run. See sweetpad help config for every key.

Destinations

--on accepts plain descriptions and resolves them against your live device list:

You writeYou get
--on "iPhone 16 Pro"The simulator or device with the closest name.
--on bootedWhatever simulator is already running.
--on macYour Mac (for macOS schemes).
--on deviceYour connected physical device.
--on ios / --on watchosAny destination of that platform.
--on work-phoneAn alias you created with sweetpad context alias.
--on <UDID>That exact simulator or device.

--destination takes the raw, exact form instead — e.g. platform=iOS Simulator,name=iPhone 16 Pro or platform=macOS — which is handy in CI where fuzzy matching would be a liability. sweetpad devices prints a copy-paste-ready specifier for everything it lists.

Exit codes and JSON output

CodeMeaning
0Success.
1Generic failure.
2Usage error — bad flags or arguments.
3The build or the tests failed.
4Couldn't resolve a target — unknown scheme, destination, simulator…
5A required tool is missing (xcodebuild, simctl, …).
6Cancelled by you — a declined prompt or Ctrl-C.

With -o json, results arrive as a one-shot envelope {"schema": 1, "ok": true, "data": …}; errors go to stderr as {"schema": 1, "ok": false, "error": {"code", "message"}} where the code mirrors the exit-code taxonomy. -o ndjson streams one JSON event per line and ends with a result event — useful for long commands like builds where you want progress as it happens.

tip

"ok": true means "the command executed", not "the outcome was good". A red test suite exits with code 3 and reports its failures inside data — check the payload, not just the envelope.

sweetpad project new

Scaffolds a minimal SwiftUI app. With no flags on a terminal it runs a short wizard; any flag you pass skips its question.

FlagDefaultWhat it does
--platform <ios|macos>iosTarget platform.
--bundle-id <id>com.example.<Name>Bundle identifier.
--deployment-target <ver>iOS 17.0 / macOS 14.0Minimum OS version.
--current-diroffScaffold into the current folder instead of a new one.
--no-gitoffSkip the initial git init.
--forceoffAllow scaffolding into a non-empty folder.