Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Is MetricKit automatically on all devices?

Hello Apple,

I am trying to get information such as crash context whenever a user encounters a situation where the app is killed. I was wondering if the tool MetricKit is available to all users or is this a feature to those who has opted into it. I am aware that the whenever someone gets a new device or in settings, an option will appear that'll have users decide whether or not to have Apple receive data analytics during certain events on their device. Does this have any effect on whether some users may not have MetricKit? Overall, we are attempting to use MetricKit to better analyze performance of our app. It would be inefficient for us, if the population of users using MetricKit is only those who have opted into it.

Thanks, dmaliro

Answered by DTS Engineer in 839573022
I was wondering if the tool MetricKit is available to all users or is this a feature to those who has opted into it.

I’ve wondered that myself, so I decided to test it. Pasted in below are some code snippets from my test app. Here’s what I did:

  1. Using Xcode 16.3, I created a small test app from the iOS > App template.

  2. I chose Product > Run to run it on my test device. It’s running iOS 18.3.1 (need to update!) but I don’t think that matters. Anything after iOS 15 should behave roughly the same way.

  3. In Xcode, I stopped the app. It’s important to test stuf like this from the Home screen, not when run from Xcode.

  4. On the device, I ran the app from the Home screen. It displays no crash diagnostics, obviously.

  5. I tapped the Crash button. The app… well… crashed.

  6. I re-ran the app from the Home screen. Now it displays a single crash metric.

  7. I disabled Settings > Privacy & Security > Analytics & Improvements > Share With App Developers.

  8. I repeated steps 5 and 6. I still get crash diagnostics.

  9. I then disabled diagnosticsSettings > Privacy & Security > Analytics & Improvements > Share iPhone Analytics.

  10. And repeated steps 5 and 6. I still get crash diagnostics.

That’s pretty cool.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


@Observable
final class AppModel: NSObject, MXMetricManagerSubscriber {

    var lastUpdate: Date? = nil
    var crashCount: Int = 0

    func start() {
        MXMetricManager.shared.add(self)
    }
    
    func didReceive(_ payloads: [MXDiagnosticPayload]) {
        self.lastUpdate = Date.now
        let crashes = payloads.compactMap { payload in
            payload.crashDiagnostics
        }
        self.crashCount += crashes.count
    }
}

struct ContentView: View {
    let model: AppModel
    var body: some View {
        VStack {
            Text(model.lastUpdate?.formatted() ?? "-")
            Text("count: \(model.crashCount)")
            Button("Crash") {
                precondition(false)
            }
        }
        .padding()
    }
}
Accepted Answer
I was wondering if the tool MetricKit is available to all users or is this a feature to those who has opted into it.

I’ve wondered that myself, so I decided to test it. Pasted in below are some code snippets from my test app. Here’s what I did:

  1. Using Xcode 16.3, I created a small test app from the iOS > App template.

  2. I chose Product > Run to run it on my test device. It’s running iOS 18.3.1 (need to update!) but I don’t think that matters. Anything after iOS 15 should behave roughly the same way.

  3. In Xcode, I stopped the app. It’s important to test stuf like this from the Home screen, not when run from Xcode.

  4. On the device, I ran the app from the Home screen. It displays no crash diagnostics, obviously.

  5. I tapped the Crash button. The app… well… crashed.

  6. I re-ran the app from the Home screen. Now it displays a single crash metric.

  7. I disabled Settings > Privacy & Security > Analytics & Improvements > Share With App Developers.

  8. I repeated steps 5 and 6. I still get crash diagnostics.

  9. I then disabled diagnosticsSettings > Privacy & Security > Analytics & Improvements > Share iPhone Analytics.

  10. And repeated steps 5 and 6. I still get crash diagnostics.

That’s pretty cool.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


@Observable
final class AppModel: NSObject, MXMetricManagerSubscriber {

    var lastUpdate: Date? = nil
    var crashCount: Int = 0

    func start() {
        MXMetricManager.shared.add(self)
    }
    
    func didReceive(_ payloads: [MXDiagnosticPayload]) {
        self.lastUpdate = Date.now
        let crashes = payloads.compactMap { payload in
            payload.crashDiagnostics
        }
        self.crashCount += crashes.count
    }
}

struct ContentView: View {
    let model: AppModel
    var body: some View {
        VStack {
            Text(model.lastUpdate?.formatted() ?? "-")
            Text("count: \(model.crashCount)")
            Button("Crash") {
                precondition(false)
            }
        }
        .padding()
    }
}

Nice :) thank you Quinn!!!

Oh, and there’s one other thing I shoulda mentioned yesterday: When MetricKit passes you data, like these crash diagnostics, you have to treat that data like you would any other potentially personal information that your app gathers. Depending on how you distribute your app, there might be policy and legal constraints on that. For example, if you ship via the App Store, I recommend you read App privacy details on the App Store.

Now, my focus is on technology, and these constraints aren’t technological, meaning that I’m not able to offer definitive answers in this space. I encourage you to do your own research, consult with relevant specialists, and so on.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is MetricKit automatically on all devices?
 
 
Q