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
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:
-
Using Xcode 16.3, I created a small test app from the iOS > App template.
-
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.
-
In Xcode, I stopped the app. It’s important to test stuf like this from the Home screen, not when run from Xcode.
-
On the device, I ran the app from the Home screen. It displays no crash diagnostics, obviously.
-
I tapped the Crash button. The app… well… crashed.
-
I re-ran the app from the Home screen. Now it displays a single crash metric.
-
I disabled Settings > Privacy & Security > Analytics & Improvements > Share With App Developers.
-
I repeated steps 5 and 6. I still get crash diagnostics.
-
I then disabled diagnosticsSettings > Privacy & Security > Analytics & Improvements > Share iPhone Analytics.
-
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()
}
}