# CrashReport

> Holds data for a single application crash event and provides access to all gathered crash reports.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public sealed class CrashReport
```

## Remarks

If compiled with appropriate settings, Unity will try to gather useful information, like location and thread stack traces, when your application crashes. Upon the next application start, if the data gathering was successful, all crash information will be accessible using this API.

To enable crash report generation, in iOS player settings set "Script Call Optimization" option to "Fast but no Exceptions". After you build your Xcode project in Unity, open it and edit trampoline file: Classes/CrashReporter.h. Change ENABLE\_CUSTOM\_CRASH\_REPORTER define from 0 to 1. Note that the iOS Player Settings has a Crash Reporting setting with an "Enable CrashReport API".

Note: this API currently is available only for iOS targets.

Additional Resources: [CrashReport.reports](/engine/6000.0/script-reference/unityengine/crashreport/reports.md).

## Examples

```csharp
using UnityEngine;


// This example shows a list of crash reports (if available),
// and allows you to output crash data to console, or
// delete them.
public class Crashes : MonoBehaviour
{
    void OnGUI()
    {
        var reports = CrashReport.reports;
        GUILayout.Label("Crash reports:");
        foreach (var r in reports)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Crash: " + r.time);
            if (GUILayout.Button("Log"))
            {
                Debug.Log(r.text);
            }
            if (GUILayout.Button("Remove"))
            {
                r.Remove();
            }
            GUILayout.EndHorizontal();
        }
    }
}
```

## Fields

| Value                                                                   | Description                          |
| ----------------------------------------------------------------------- | ------------------------------------ |
| [text](/engine/6000.0/script-reference/unityengine/crashreport/text.md) | Crash report data as formatted text. |
| [time](/engine/6000.0/script-reference/unityengine/crashreport/time.md) | Time, when the crash occured.        |

## Static Properties

| Property                                                                            | Description                                                     |
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [lastReport](/engine/6000.0/script-reference/unityengine/crashreport/lastreport.md) | Returns last crash report, or null if no reports are available. |
| [reports](/engine/6000.0/script-reference/unityengine/crashreport/reports.md)       | Returns all currently available reports in a new array.         |

## Methods

| Method                                                                      | Description                                |
| --------------------------------------------------------------------------- | ------------------------------------------ |
| [Remove](/engine/6000.0/script-reference/unityengine/crashreport/remove.md) | Remove report from available reports list. |

## Static Methods

| Method                                                                            | Description                                     |
| --------------------------------------------------------------------------------- | ----------------------------------------------- |
| [RemoveAll](/engine/6000.0/script-reference/unityengine/crashreport/removeall.md) | Remove all reports from available reports list. |
