Find unused classes within your app

Reaper detects unused code in your app. It is in a private beta, contact us if you’d like to try it in your app.

Why does dead code detection and deletion matter?

Over time, dead code can accumulate until it starts to take up a real chunk of the app. This can be due to A/B test branches that are no longer used, helper classes for long-deleted features, or all other manner of things. This has the following issues:

  • Increased build time, due to compiling code that won’t be needed
  • Worse code cleanliness, with unused classes polluting the file structure, grep results, etc.
  • Longer startup time, because it will take up extra space in the binary that usually gets loaded from disk (for a deeper dive into how a binary is loaded from disk, see our blog post.

How does Reaper work?

Reaper is an SDK that you can put into your production or alpha users' apps to report which Swift and Objective-C classes were used for each user session. We take those reports and generate a list of all the classes in the binary, for each version of your app. The SDK will detect unused classes within the main binary specifically, not in dynamic frameworks. It's easy to integrate, either as a standalone binary or as a Cocoapod, and adds very little overhead to your app.

Reaper supports iOS 15, 16, and 17. It supports all classes written in Objective-C and most classes written in Swift.

Performance Implications

The SDK adds less than 20kb to the binary size, and less than 1ms to startup time. The SDK will not run any code if you don't initialize it at launch. If you do initialize it, the initialization is synchronous so you can measure exactly how long it takes, we expect under 1ms.

The SDK starts running upon receiving UIApplicationDidEnterBackgroundNotification or UIApplicationWillTerminateNotification. This way it doesn't run while the user is interacting with your app. It makes one network request per notification, containing:

  1. List of used classes
  2. App bundle id
  3. App version
  4. Metadata used to identify the request on the Emerge backend

The data in this network request is compressed, and typically under 20kb but the size can vary based on how many used classes there are. The same classes are not uploaded on every notification, each class is uploaded at most once per app launch to save user data.