# Static analysis for Swift

A local CLI that traces reachability across Swift declarations and identifies candidates for unused code.

> Advisory preview · exact macOS profile · local analysis

[Documentation](https://swift-analyzer.com/en/docs/)

[CLI reference](https://swift-analyzer.com/en/cli/)

## Read the program as one build snapshot

Swift Analyzer connects declarations, references, roots, and explicit dynamic boundaries from one prepared build snapshot.

### Reachability

Declaration and reference analysis within a specific build snapshot.

### Explanations

Evidence, assumptions, and limitations for individual results.

### Local execution

Existing compiler data as input. Canonical JSON as output.

## Command-line interface

doctor validates the input snapshot. scan performs the analysis. why explains a result by its exact identifier.

For automation, preserve the JSON report and exit code. Exit 3 indicates incomplete capability.

```sh
swift-analyzer doctor --manifest snapshot.json --format human
swift-analyzer scan --manifest snapshot.json --format json
```

> Example command syntax. Prepare snapshot.json for your build before running these commands.

## Compiler data as input

The analyzer consumes an existing Index Store and a manifest for one build variant. Project preparation is a separate step.

Incomplete inputs or unmodeled dynamic behavior leave affected conclusions unknown. The absence of known references does not prove that code is unused.

## Current boundary

The documented capability is advisory-only for one exact validated profile. There is no automatic deletion, default blocking findings gate, or public binary download in the current release documentation.

Team workflows and a hosted service are planned. The current scope is the local CLI.

---
Language: en
Canonical: https://swift-analyzer.com/en/
Source revision: aaccde765dee97b46d111bd5f6493e17f55d086e
Catalog revision: 4558458d
Availability: local advisory preview; hosted service planned and unavailable.
