You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: platform-includes/capture-error/apple.mdx
+32-11Lines changed: 32 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,28 +103,49 @@ The SDK can't install the uncaught exception handler if a debugger is attached.
103
103
104
104
</Note>
105
105
106
-
By default, macOS applications do not crash whenever an uncaught exception occurs. To enable this with Sentry:
106
+
By default, macOS applications do not crash whenever an uncaught exception occurs. As the Cocoa Frameworks are generally not [exception-safe on macOS](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Exceptions/Articles/ExceptionsAndCocoaFrameworks.html), we recommend this approach because the application could otherwise end up in a corrupted state.
107
+
108
+
To capture uncaught NSExceptions, you can use the `SentryCrashExceptionApplication` or enable the option `enableUncaughtNSExceptionReporting,` available as of version [8.40.0](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8400). Once you have configured your application to crash whenever an uncaught exception occurs, the Apple SDK will capture those automatically. You don't need to manually call `captureException`.
109
+
110
+
### SentryCrashExceptionApplication
111
+
112
+
<Alertlevel="warning">
113
+
114
+
Don't use this option together with the `enableUncaughtNSExceptionReporting` option. Enabling both features can lead to duplicated reports.
115
+
116
+
</Alert>
117
+
118
+
To enable this with Sentry:
107
119
108
120
1. Open the application's `Info.plist` file
109
121
2. Search for `Principal class` (the entry is expected to be `NSApplication`)
110
122
3. Replace `NSApplication` with `SentryCrashExceptionApplication`
111
123
112
-
Alternatively, you can set the `NSApplicationCrashOnExceptions` flag:
Don't use this option together with the `SentryCrashExceptionApplication`. Enabling both features can lead to duplicated reports.
119
129
120
-
SentrySDK.start { options in
121
-
// ...
122
-
}
130
+
</Alert>
123
131
124
-
returntrue
132
+
As of version [8.40.0](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8400), you can enable uncaught NSException reporting by setting the `enableUncaughtNSExceptionReporting` option to `true`. This is especially useful for applications using the SwiftUI lifecycle in combination with the [`NSApplicationDelegateAdaptor`](https://developer.apple.com/documentation/swiftui/nsapplicationdelegateadaptor), for which you can't easily use the `SentryCrashExceptionApplication` class.
133
+
134
+
```swift {tabTitle:Swift}
135
+
importSentry
136
+
137
+
SentrySDK.start { options in
138
+
options.dsn="___PUBLIC_DSN___"
139
+
options.enableUncaughtNSExceptionReporting=true
125
140
}
126
141
```
142
+
```objc {tabTitle:Objective-C}
143
+
@import Sentry;
127
144
128
-
Once you have configured your application to crash whenever an uncaught exception occurs, the Apple SDK will capture those automatically. You don't need to manually call `captureException`.
0 commit comments