lethen_

Find dead code in Swift. See why it is dead.

Lethen reads the compiler's index store, so it sees what the compiler sees. Every finding is certain or likely, with the reference chain to prove it.

$brew install albovsky/tap/lethen

macOS 15 or later (Apple silicon) and Linux. Swift 6.3 or later. MIT licensed.

~/Projects/Storelethen scan
$ lethen scan --verbose
Sources/Store.swift:12:10: warning: Unused function 'reload()'
    reason: no references in the scanned modules
Sources/Cache.swift:40:7: warning: Unused class 'LegacyCache'
    reason: only referenced by unused code
Sources/Bridge.swift:8:16: warning: Unused property 'tag'
    confidence: likely
    reason: Objective-C could reach this by name
3 results, 1 likely.

$ lethen explain Store.reload
Store.reload() is unused: certain.
No declaration in the scanned modules references it.

How it works

A result tells you why

likely means something dynamic, such as Objective-C or a name in a string, could still reach the declaration.

Gate CI on what Lethen is sure about

$ lethen scan --min-confidence certain --strict

Add --write-baseline once, and later scans report only new results.

Ask why something is used or unused

$ lethen explain Store.load

Output as xcode, json, csv, github-actions or gitlab-codequality.

Features

Built for real projects

SwiftPM, Xcode and Bazel, with the configuration you already have.

Confidence and reasons

Every result is certain or likely, with a reason. --min-confidence lets CI fail only on what Lethen is sure about.

Store.swift:12: warning: Unused function 'reload()' certain no references in the scanned modules Bridge.swift:8: warning: Unused property 'tag' likely Objective-C could reach this by name

lethen explain

The shortest reference chain, or the rule that retained it.

Store.load()←Feed.refresh()←App

Objective-C aware

Swift called from a .m file counts as used.

Feed.m→FeedViewModel.swift

SwiftPM, Xcode, Bazel

Managed scans, or your own index store with --skip-build.

Package.swift.xcodeprojWORKSPACE

Never reads a stale index

A build is reused only when its index verifies; otherwise it rebuilds.

build→verify→reuseorclean

GitHub Action and plugin

Annotates unused code on pull requests. A SwiftPM plugin runs the same scan.

uses: albovsky/lethen@v3 ✓ 2 new unused, 0 fixed

Periphery compatible

Your configuration, ignore comments and library name keep working.

.periphery.yml// periphery:ignorePeripheryKit

Periphery's engine, improved results. Fewer false positives, a confidence level and a reason on every finding.

Accuracy

Measured in the open

Every analysis change re-scans pinned open-source projects, and each changed finding is checked by hand.

84.0 %precision

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

Scorecard and method.

By project, against the target

Alamofire
96.7 %
swift-nio
88.0 %
Wikipedia iOS
65.4 %
All 81
84.0 %

95 % target. Samples: Alamofire 30, swift-nio 25, Wikipedia iOS 26.

Compared with Periphery

Fewer findings, and the differences checked

Lethen 3.10 against the latest Periphery release, 3.8.0, on five projects, with the source behind every difference read by hand.

ProjectPeripheryLethenWhat the differences were
swift-format2929Identical.
Alamofire9671All 30 Periphery-only findings were false positives or public API.
swift-argument-parser8078Periphery-only: 8 public API, 1 debatable, 1 true positive. Lethen-only: 8 true positives.
swift-nio45131515 sampled Periphery-only: 12 false positives, 3 public API, 0 true positives.
Wikipedia iOS3,2122,78310 of 15 sampled Periphery-only groups were Swift called from Objective-C.
How this was measured

Results with --retain-public, except Wikipedia iOS. 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.

Not faster: cold scans were roughly equal. Lethen has recall losses of its own, such as unused imports in Objective-C files, and 22 % of Wikipedia iOS findings are only likely. Known issues are on GitHub.

Open source

Open source, down to every finding

MIT licensed. The analysis, the precision corpus and the release pipeline are all in the repository. No account, no telemetry, no paid tier.

The graph is what a scan walks. Whatever it never reaches is reported.

View on GitHub

Install

Up and running in two commands

On macOS, Xcode or the Command Line Tools must be installed.

Homebrew (Apple silicon)

$ brew install albovsky/tap/lethen
$ lethen version

macOS zip

Signed and notarized, on every release.

Linux

x86_64 and aarch64 tarballs, glibc 2.35 or later. Steps.

From source

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

Also the route for Intel Macs.

Then scan

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

Xcode projects: --project App.xcodeproj --schemes App. Guide.

In GitHub Actions

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

Release 3.10.0 or later. On Linux, use a Swift 6.3+ container such as swift:6.4-noble.