read

Periphery is one of my favorite tool. It works well to scan a project and provide warnings for those unused code. It’s a good chore to declutter your codes once in a while. You might even spot bugs!

This is a short guide to setting up Periphery for a new project.

Step 1: Install

brew install peripheryapp/periphery/periphery

Step 2: Setup

With brew install, you can now run periphery on your CLI. Run setup in your project directory.

periphery scan --setup

It will create a .periphery.yml specifying the scheme and target to check for unused code.

While you can already run periphery scan to build and show you the codes that are unused, it is much more convenient to run in Xcode and show you the code as Xcode warnings.

Step 3: Integrate in Xcode

There is a guide on how to integrate in Xcode. In short:

  • Add new Aggregate target
  • Add a Run Script Build Phase (see below)
  • Select scheme and build

If you follow the official guide, there is an error:

periphery: command not found

To fix, the Run Script should be the following:

eval "$(/opt/homebrew/bin/brew shellenv)"
periphery scan --format xcode

The eval .. brew shellenv is needed because Xcode does not load the brew bin PATH.


Image

@samwize

¯\_(ツ)_/¯

Back to Home