Swift CLI
$ swift Official Low RiskOfficial CLI driving the Swift compiler and Swift Package Manager (swift build, swift test, swift package). Exposes swift package dump-package and swift package show-dependencies --format json for structured dependency graphs without triggering builds.
brew install swift Local Swift toolchain and SwiftPM orchestrator; runs directly on Package.swift workspaces.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
OVERVIEW: Swift compiler
USAGE: swift
OPTIONS:
-access-notes-path <value>
Specify YAML file to override attributes on Swift declarations in this module
-allow-availability-platforms <platforms>
Restrict availability metadata to the given platforms, e.g. 'macOS,Swift'
-allow-non-resilient-access
Ensures all contents are generated besides exportable decls in the binary module, so non-resilient access can be allowed
-allowable-client <vers>
Module names that are allowed to import this module
-assert-config <value> Specify the assert_configuration replacement. Possible values are Debug, Release, Unchecked, DisableReplacement.
-block-availability-platforms <platforms>
Remove the given platforms from symbol graph availability metadata, e.g. 'macOS,Swift'
-build-id <build-id> Specify the build ID argument passed to the linker
-cache-compile-job Enable compiler caching
-cache-disable-replay Skip loading the compilation result from cache
-cas-path <path> Path to CAS
-cas-plugin-option <name>=<option>
Option pass to CAS Plugin
-cas-plugin-path <path> Path to CAS Plugin
-clang-build-session-file <value>
Use the last modification time of <file> as the underlying Clang build session timestamp
-clang-scanner-module-cache-path <value>
Specifies the Clang dependency scanner module cache path
-clang-target-variant <value>
Separately set the target we should use for internal Clang instance for the 'zippered' code for macCatalyst
-clang-target <value> Separately set the target we should use for internal Clang instance
-color-diagnostics Print diagnostics in color
-compiler-assertions Enable internal self-checks while compiling
-const-gather-protocols-list <path>
Specify a list of protocols for extraction of conformances 'const values'
-continue-building-after-errors
Continue building, even after errors are encountered
-coverage-prefix-map <prefix=replacement>
Remap source paths in coverage info
-cxx-interoperability-mode=<value>
Enables C++ interoperability; pass 'default' to enable or 'off' to disable
-debug-info-format=<value>
Specify the de FCRS-1.0 6-Dimension Breakdown
swift package dump-package and show-dependencies --format json return clean JSON, though swift build and swift test emit text diagnostics.
dump-packageandshow-dependencies --format jsonsupport- Non-interactive
swift buildandswift test
Local compilation with no remote write commands, though evaluating Package.swift runs Swift code in a sandboxed manifest process.
- Local-only writes to
.build/andPackage.resolved
Preinstalled on macOS via Xcode CLT and officially supported on Linux, while Windows and Xcode-framework builds require heavier setup.
- First-class on macOS/Linux; partial ecosystem parity on Windows
Unified compiler, formatter/testing integration, and SwiftPM dependency resolver.
- Covers builds, testing, and package management in one binary
Official Swift.org project maintained by Apple and the Swift community under Apache-2.0.
- Official
swiftlang/swiftrepository
Clear Swift.org documentation and subcommand --help hierarchy.
- Official docs at swift.org/documentation
Security, Auth & Guardrails
Public packages require no auth; private Swift registries use ~/.swiftpm/configuration/registries.json or system git credentials.
Apache-2.0 open-source toolchain; completely free.
# Swift CLI (swift) Agent Rules - Use `swift package dump-package` and `show-dependencies --format json` to inspect `Package.swift` cleanly. - Note that `Package.swift` executes arbitrary Swift code during evaluation; inspect untrusted manifests before running.
Agent-Ready Command Recipes
Safe Read-Only Queries
swift package dump-package
Evaluates Package.swift and prints the package targets, products, and dependencies as JSON.
swift package show-dependencies --format json
Outputs the resolved SwiftPM dependency tree in JSON.
Controlled Writes & Previews
swift test --parallel
Compiles targets and executes XCTest/Swift Testing suites concurrently.
Strengths for Agents
- +
swift package dump-packageandshow-dependencies --format jsonparsePackage.swiftreliably. - + Seamless integration of compiler, SwiftPM, and
swift test.
Caveats & Pitfalls
- !
swift buildandswift testcompiler errors are plain text lines rather than JSON. - ! iOS/UIKit targets still require
xcodebuildon macOS rather than standaloneswift build.