Periphery logo

Eliminate Unused Swift Code

Periphery analyzes Swift projects to identify unused code

Periphery is now open-source!

Please bare with us while we migrate all documentation to GitHub.


Get Started

Unused Code Is a Burden

Are your refactorings complicated by awkward code that might no longer be needed?
How many minutes do you waste every day reading unused code?

As any good chef will attest to, keeping your workspaces clean and tidy is fundamental. We believe the same applies to software - keeping your projects free of unused code is fundamental practice of professional software development.

Take pride in your work. Keep it clean.

Read our Manifesto

Comprehensive Analysis

Periphery can identify a wide range of unused declarations in your project.
Swift alternative logo
  • Classes, structs & protocols
  • Functions, parameters & properties
  • Enums & individual cases
  • Type aliases & associated types

More than a simple reference checker…

Periphery applies advanced analytical heuristics to identify unused code that a simple reference checker would have no hope of finding.

To Periphery code is more than a static graph of nodes and edges; Periphery mutates your application's structure in memory to detangle a multitude of self-referential, semantic & redundant references.

Unused Function Parameters

Unused function parameter analysis helps keep your interfaces clean.

'name' is unused
'name' is unused
protocol Greeter { func greet(name: String) func farewell(name: String) } class InformalGreeter: Greeter { func greet(name: String) { print("Sup " + name + ".") } func farewell(name: String) { print("Cya.") } }

Periphery not only identifies simple cases of unused parameters, it also takes into account the context of your application.

A parameter of a protocol function will only be identified as unused if the parameter is also unused in all implementations.

The same applies to overidden functions, parameters are only identified as unused if they're also unused in the base function and all overriding functions.

Learn more about function parameter analysis

Redundant Protocols

Redundant protocol conformance is a prime example of Periphery's analytical power.

'Greeter' is unused
protocol Greeter { func greet() } class MyGreeter: Greeter { func greet() { print("Hello, World!") } } let greeter = MyGreeter() greeter.greet()

Periphery can identify protocols that are conformed to, but which are not directly used in a specialization. In this example, Greeter can be removed.

These situations can be hard to identify with the naked eye, especially if the protocol is conformed to by multiple classes spanning multiple files.

Learn more about protocol analysis

Assign-only Properties

Identification of assign-only properties is perfect for rooting out unused dependencies.

'presenter' is unused
class Greeter { static func make() -> Self { return self.init(presenter: inject()) } let presenter: Presenter init(presenter: Presenter) { self.presenter = presenter } func greet() { print("Hello, World!") } }

Periphery can identify properties that are assigned a value, but which are never read from.

Often when removing old features the focus is on deleting functions, properties once used by those functions can easily slip under the radar.

If you do dependency injection via the constructor, you'll love this feature!

Learn more about assign-only properties

Xcode Integration

Xcode integration example

Periphery outputs results in a format Xcode understands. Unused code is highlighted as warnings, just like you're accustomed to with other build warnings.

Integration is as simple as creating an Aggregate build target with a Run Script phase.

Xcode Integration Guide

We Command Line Junkies
Periphery is primarily a command line driven tool, rest assured you can use it without ever touching a mouse!

Your Code Is Safe

The safety of your intellectual property is paramount.

That's why Periphery performs 100% of its analysis locally, on your computer. That means no remote services, your code simply never leaves your computer.

Learn more about validating the security of Periphery