<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/CrashDiagnostic",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit15CrashDiagnosticV"
  },
  "title" : "CrashDiagnostic"
}
-->

# CrashDiagnostic

A diagnostic report that describes a crash that occurred.

```
struct CrashDiagnostic
```

## Discussion

This carries a [`CallStackTree`](/documentation/MetricKit/CallStackTree) along with crash-specific metadata including the exception type, exception code, signal, and optional Objective-C exception reason.

Use [`terminationCategory`](/documentation/MetricKit/CrashDiagnostic/terminationCategory-swift.property) to correlate this crash with the aggregate termination counts in [`ForegroundTerminationMetric`](/documentation/MetricKit/ForegroundTerminationMetric) and [`BackgroundTerminationMetric`](/documentation/MetricKit/BackgroundTerminationMetric):

```swift
if let category = diagnostic.terminationCategory {
    switch category {
    case .watchdog:
        flagWatchdogTermination()
    case .badAccess:
        flagBadAccessCrash()
    default:
        break
    }
}
```

## Topics

### Call stack

[`let callStackTree: CallStackTree`](/documentation/MetricKit/CrashDiagnostic/callStackTree)

The application call stack tree associated with this crash.

### Exception details

[`let exceptionType: Int?`](/documentation/MetricKit/CrashDiagnostic/exceptionType)

The name of the Mach exception that terminated the app.

[`let exceptionCode: UInt64?`](/documentation/MetricKit/CrashDiagnostic/exceptionCode)

Processor specific information about the exception.

[`let signal: Int?`](/documentation/MetricKit/CrashDiagnostic/signal)

The signal associated with this crash.

[`let exceptionReason: CrashDiagnostic.ObjectiveCExceptionReason?`](/documentation/MetricKit/CrashDiagnostic/exceptionReason)

The exception reason for an uncaught ObjC exception.

[`let virtualMemoryRegionInfo: String?`](/documentation/MetricKit/CrashDiagnostic/virtualMemoryRegionInfo)

Details about memory that the app incorrectly accessed.

### Termination counts

[`let terminationCategory: CrashDiagnostic.TerminationCategory?`](/documentation/MetricKit/CrashDiagnostic/terminationCategory-swift.property)

The category of termination that caused this crash.

[`let terminationReason: CrashDiagnostic.TerminationReason?`](/documentation/MetricKit/CrashDiagnostic/terminationReason-swift.property)

The reason the app was terminated as a human-readable string.

### Structures

[`struct ObjectiveCExceptionReason`](/documentation/MetricKit/CrashDiagnostic/ObjectiveCExceptionReason)

Detailed information about an uncaught Objective-C exception that caused a crash.

[`struct TerminationCategory`](/documentation/MetricKit/CrashDiagnostic/TerminationCategory-swift.struct)

A value that describes the category of termination that caused a crash.

[`struct TerminationReason`](/documentation/MetricKit/CrashDiagnostic/TerminationReason-swift.struct)

A value that describes the reason the app terminated.

## Relationships

### Conforms To

[`Decodable`](/documentation/Swift/Decodable)

[`Encodable`](/documentation/Swift/Encodable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)