MetricKit is the Apple framework that collects performance metrics and diagnostic reports on real users’ devices and delivers them to the app itself as aggregated payloads. In mobile performance work on iOS, iPadOS and macOS, it is the first-party source of field data on launch time, hangs, battery use, memory, disk writes and crashes, gathered by the operating system rather than by custom instrumentation.
Apple introduced MetricKit in iOS 13 and expanded it substantially in iOS 14 with diagnostic payloads. Because the system measures the app from the outside, the data covers events that in-app code cannot see on its own, such as watchdog terminations, memory-pressure exits and the energy cost of background work.
How MetricKit collects and delivers data
MetricKit works on a subscriber model. The app registers an object conforming to MXMetricManagerSubscriber with the shared MXMetricManager, and the system calls that subscriber when new payloads are ready. Registration usually happens early at launch so that no delivery is missed.
The operating system records measurements continuously, aggregates them on the device and hands them over in two payload types. The table summarizes how they differ.
| Payload | Content | Delivery timing |
|---|---|---|
| MXMetricPayload | Aggregated metrics and histograms for a reporting window | At most once per day, covering about 24 hours |
| MXDiagnosticPayload | Crash, hang, CPU and disk-write exception reports with call stacks | Daily on iOS 14, immediately on iOS 15 and later |
Each payload exposes a jsonRepresentation() method, so teams typically upload the raw JSON to their own backend and analyze it there. Data comes only from devices whose owners agreed to share analytics with app developers, which means the sample is real but not complete.
Metric categories and what they reveal
MetricKit groups measurements into typed metric classes, each describing one aspect of performance or energy use. Many values arrive as histograms rather than averages, which lets engineers see the slow tail that a mean would hide.
| Metric class | Key values | Typical question answered |
|---|---|---|
| MXAppLaunchMetric | Time to first draw, resume time | Is cold start getting slower after a release |
| MXAppResponsivenessMetric | Hang time histogram | How often is the main thread blocked |
| MXAnimationMetric | Scroll hitch time ratio | Is scrolling visibly janky |
| MXCPUMetric and MXGPUMetric | Cumulative CPU and GPU time | What drives battery drain |
| MXMemoryMetric | Peak memory, average suspended memory | Why is the app killed in the background |
| MXDiskIOMetric | Cumulative logical writes | Does the app wear storage excessively |
| MXAppExitMetric | Counts of normal and abnormal exits by reason | How many silent terminations occur |
Developers can add custom measurements with mxSignpost, which records intervals around specific operations such as loading a feed. These appear as MXSignpostMetric entries in the daily payload alongside the system metrics.
Diagnostics for crashes, hangs and exceptions
Diagnostic payloads explain why a problem happened, not only how often. Each diagnostic carries metadata such as the app version, device type and operating system build, together with a call stack tree that shows where the main thread or the crashing thread was at the time.
- Crash diagnostics include the exception type, signal and termination reason.
- Hang diagnostics record main-thread stalls together with their duration.
- CPU exception diagnostics flag code that exceeded the system’s CPU usage limits.
- Disk write exception diagnostics report code that wrote more data than allowed in a period.
Call stacks arrive unsymbolicated, as binary images and offsets. Teams must match them against the dSYM files of each build to obtain readable function names, which is the most common integration hurdle.
Diagnostics are especially valuable for terminations that bypass signal handlers, such as a watchdog kill during a slow launch or a memory-limit exit in the background. In-process crash reporters often miss these events entirely, so MetricKit is frequently the only reliable record of them. Since iOS 15, immediate delivery also lets teams detect a crash spike within hours of a release instead of waiting for the next daily report.
MetricKit compared with other performance tools
MetricKit is one source among several, and it complements rather than replaces lab profiling and third-party crash reporting. The comparison clarifies where it fits.
| Tool | Data source | Main strength |
|---|---|---|
| MetricKit | Operating system on user devices | System-level field data, including watchdog exits |
| Xcode Organizer | Aggregated MetricKit-style data in Xcode | No code needed, cohort trends by version |
| Xcode Instruments | Local profiling sessions | Deep traces for reproducing a problem |
| Crash analytics SDKs | In-process signal handlers | Real-time alerts and rich custom context |
| Android vitals | Google Play aggregated device data | Equivalent field metrics on Android |
A practical split is to use Instruments to diagnose a problem in the lab, MetricKit and the Organizer to measure its real-world impact, and a crash reporting SDK when the team needs immediate alerting rather than daily batches.
Limitations and integration mistakes
MetricKit is delayed, sampled and aggregated by design, which protects privacy and battery life but limits how it can be used. The table lists frequent problems.
| Symptom | Cause | Remedy |
|---|---|---|
| No payloads arrive | Subscriber registered too late or released | Register at launch and keep a strong reference |
| Unreadable stack traces | Missing symbolication | Archive dSYM files for every build |
| Small sample size | Few users share analytics | Treat trends as indicative, not exact |
| Cannot test locally | Payloads appear only after a day | Use the Xcode option to simulate payloads |
Because payloads lack per-user identifiers, MetricKit cannot trace a single session end to end. Teams that need that level of detail combine it with their own logging, while keeping MetricKit as the authoritative view of system-measured behavior.
Explained without jargon
MetricKit is like a daily health report that the iPhone writes about an app. The phone quietly notes how long the app takes to open, how often it freezes, how much battery it uses and whether it crashed.
Once a day, the phone hands this summary to the app, which can send it to its developers. Only people who agreed to share data take part. The developers then see how the app really behaves in everyday use, not just on their own test phones.
A typical use case
A team building a grocery delivery app notices rising complaints about freezes after a release, yet nothing reproduces on test devices. They already upload MetricKit payloads to their analytics backend, so they compare the hang time histograms of the old and new versions.
The data shows that the share of sessions with hangs longer than 250 milliseconds has roughly tripled on older iPhones. Hang diagnostics point to the same call stack in most reports: a synchronous database migration that runs on the main thread when the cart screen opens.
Engineers move the migration to a background queue and add an mxSignpost interval around cart loading. Over the next two weeks of daily payloads, the hang rate returns to its earlier level and cart load time drops by about 40 percent, confirming the fix with field data rather than assumptions.