Skip to content

False positive: method implementing a protocol requirement reported as unused #1092

@mathewlee83

Description

@mathewlee83

Describe the bug
A class implements a protocol method (the method satisfies a protocol requirement). That same method is called on a concrete instance of the class in the app target. At runtime the call runs as expected, but Periphery still reports the method as unused — a false positive. It looks like the tool does not correctly connect protocol witness implementations to call sites on the concrete type (or similar indexing/analysis gap).

Reproduction

  1. Define a protocol with a method (e.g. build()).
  2. Implement that method on a conforming class.
  3. In another file in the same target, create an instance of that class and call the method on that instance (not only through a protocol-typed property).
  4. Run periphery scan on the Xcode project.

Actual: The implementing method is flagged as unused.
Expected: It should not be reported as unused.

(Optional: attach a minimal Xcode sample project that follows the steps above if maintainers need a repro.)

Environment
Copy the output from running:

periphery version
3.6.0
swift -version
swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0
xcodebuild -version
Xcode 26.1.1
Build version 17B100

[PeriPheryTest.zip](https://github.com/user-attachments/files/26073642/PeriPheryTest.zip)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions