A tool to identify unused code in Swift projects, including advanced cases like redundant protocols and assign-only properties.
Periphery is a command-line tool that statically analyzes Swift projects to find unused code. It helps developers remove dead code, reduce technical debt, and optimize their codebases by identifying everything from simple unused classes to complex patterns like redundant protocol conformances and assign-only properties.
Swift developers and teams working on iOS, macOS, or server-side Swift projects who want to maintain clean, efficient, and maintainable codebases, especially in large or long-lived applications.
Developers choose Periphery for its deep integration with Swift's build systems (Xcode, SwiftPM, Bazel), its ability to detect advanced unused code patterns that simpler linters miss, and its practical features like comment commands and CI integration that make it usable in real-world workflows.
A tool to identify unused code in Swift projects.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Identifies complex patterns like unused function parameters in protocols, redundant public accessibility, and assign-only properties, going beyond simple reference counting as detailed in the Analysis section.
Seamlessly works with Xcode, Swift Package Manager, and Bazel, including guided setup and CI pipeline support with skip-build options, making it practical for real-world workflows.
Supports comment commands like // periphery:ignore to exclude specific code from results, allowing teams to retain necessary unused code without false positives.
Offers options for mixed-language projects and parses Interface Builder files to account for @IBOutlet and @IBAction references, reducing false negatives in iOS/macOS apps.
Requires understanding of numerous command-line options, YAML configuration, and build system specifics, with a steep learning curve for optimal use, as shown in the guided setup and troubleshooting sections.
The README admits known bugs in Swift's index store that cause incorrect results, such as with static property getters and string interpolation, requiring manual workarounds or ignored results.
Must build the project first to generate the index store, which can be time-consuming for large codebases and problematic in CI without cached builds, as noted in the Continuous Integration section.