Lethen.

Find unused Swift code you can trust.

Lethen is an open-source dead-code analyzer for Swift. It reads the compiler's index store, so it sees what the compiler sees, and it tells you how sure it is and why for every result.

brew install albovsky/tap/lethen
Other ways to install Read the guide

Apple silicon Macs (the package minimum is macOS 15, but runs on macOS 15 are not yet verified; macOS 26 and 27 are) and Linux (x86_64, aarch64). Needs Swift 6.3 or later to build your project. MIT licensed. No account or paid plan needed. Confidence levels, lethen explain, --min-confidence and the GitHub Action are in release 3.10.0 and later.

A result tells you why

Each result is certain or likely. likely means a dynamic feature, such as Objective-C or a name in a string literal, could reach the declaration without a reference Lethen can see. lethen explain shows the reference chain, the rule that retained a declaration, or the only unused code that mentions it.

Scan

$ lethen scan --verbose
Sources/Store.swift:12:10: warning: Unused function 'reload()'
    reason: no references in the scanned modules
3 results, 1 likely. `lethen explain <name>` shows why;
`--write-baseline baseline.json` records these so the
next scan reports only new ones.

Gate CI on what Lethen is sure about

$ lethen scan --min-confidence certain --strict
$ lethen explain Store.load

Output formats include xcode, json, csv, github-actions, github-markdown, gitlab-codequality and codeclimate.

Built for real projects

Lethen scans SwiftPM packages, Xcode projects and Bazel workspaces, and keeps the configuration you already have.

Confidence and reasons

Every result is certain or likely with a one-sentence reason. --min-confidence filters on it.

lethen explain

Answers "why is this used or unused" with the shortest reference chain or the retaining rule.

Objective-C aware

Reads the index clang writes for Objective-C files, so a Swift declaration called from a .m file counts as used.

SwiftPM, Xcode, Bazel

Managed SwiftPM scans, Xcode schemes and configurations, and Bazel mode. Pass an index store with --skip-build to reuse your own build.

Never reads a stale index

A SwiftPM build is reused only when Lethen can verify its index; otherwise it cleans and rebuilds. --clean-build always cleans.

GitHub Action and plugin

From release 3.10.0, uses: albovsky/lethen@<version> annotates unused code on pull requests, and a SwiftPM command plugin runs it from a package or Xcode.

Baselines

Record today's results once, then fail only on new ones.

Periphery compatible

.periphery.yml, // periphery:ignore comments and the PeripheryKit library name keep working.

Accuracy, measured in the open

Every analysis change re-scans a corpus of pinned open-source projects, and each changed finding is checked by hand against the project's source before it is recorded.

84.0 % precision

On 81 sampled findings across Alamofire, swift-nio and Wikipedia iOS. The target is 95 %, so this is not there yet. The first measurement, on 2026-09-27, was 73 %.

ProjectSampledPrecision
Alamofire3096.7 %
swift-nio2588.0 %
Wikipedia iOS2665.4 %

Precision is true positives over true plus false positives in the sample. Scorecard and method.

Compared with Periphery

Lethen is a fork of Periphery and shares most of its analysis. On 2026-10-02 we scanned five projects (listed below) with Lethen 3.10.0 and Periphery 3.8.0 (the latest upstream release), and checked the differences by reading the source. Results with --retain-public, except Wikipedia iOS.

ProjectPeripheryLethenWhat the differences were
swift-format2929Identical.
Alamofire9671All 30 findings only Periphery reports were false positives or unactionable public API parameters.
swift-argument-parser8078Of the 10 findings only Periphery reports, 8 were unactionable public API, 1 was debatable and 1 was a true positive that Lethen reports at a different level. All 8 findings only Lethen reports were true positives.
swift-nio451315Of 15 sampled Periphery-only findings, 12 were false positives, 3 unactionable API and none a true positive.
Wikipedia iOS3,2122,78310 of 15 sampled Periphery-only groups were Swift code called from Objective-C.
How this was measured

Lethen 3.10.0 is master at d7dec6c. Periphery 3.8.0 is upstream tag 3.8.0 (a2db299), the latest upstream release. Both were built from source with swift build -c release. Alamofire, swift-argument-parser, swift-format and swift-nio ran on Linux x86_64 with Swift 6.4 (swift-6.4-RELEASE), at commits bda9ed5, 1021ac8, b15dd59 and feaf4ac, with --retain-public --format json --quiet --disable-update-check. Wikipedia iOS ran at 599e4a6 on an arm64 Mac with Xcode 27.0 (27A266a), Swift 6.4 and macOS 27, with --project Wikipedia.xcodeproj --schemes Wikipedia -- -destination "generic/platform=iOS Simulator".

Findings were matched on file, line, name and hint. For each project, every finding reported by only one tool was listed, and up to 15 per direction were checked by reading the source and, for Lethen, with lethen explain. The raw scan output is not published yet, so treat these numbers as a measurement we made, not a reproducible benchmark.

Lethen was not faster: cold scans were roughly equal, and its SwiftPM build reuse falls back to a full rebuild on some packages. Periphery 3.8.0 returned stale results after a source edit in our test, while Lethen rebuilt and got it right. Lethen reports fewer findings in total, mostly by policy, and has small recall losses of its own, such as unused imports in Objective-C files. Xcode scans are slow, and 22 % of Wikipedia iOS findings are only likely. Known issues are tracked on GitHub.

Install

Lethen loads Xcode's indexing library at launch, so macOS needs Xcode or the Command Line Tools installed.

Homebrew (Apple silicon)

brew install albovsky/tap/lethen
lethen version

macOS zip

Signed and notarized, with a SHA256SUMS file, attached to every release.

Linux

Release tarballs for x86_64 and aarch64 need glibc 2.35 or later and Swift 6.3+. Steps.

From source

git clone https://github.com/albovsky/lethen
cd lethen
swift build -c release --product lethen

The only route for Intel Macs.

Then scan

lethen scan --project-root /path/to/project

Xcode projects need --project App.xcodeproj --schemes App. See the guide for each project type.

In GitHub Actions

- uses: albovsky/lethen@<version>
  with:
    baseline: baseline.json

The action is available from release 3.10.0, so use a version tag at or after it. On Linux, run the job in a Swift 6.3 or later container, such as swift:6.4-noble.