From 5ded22a2286b5495da7f9c881f9c4642c057c240 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Fri, 6 Jun 2025 10:18:06 +0200 Subject: [PATCH] feat(apple): Code for NSExceptions in configure Add code snippet for reporting uncaught NSExceptions on macOS, because users often miss that step during setup. --- docs/platforms/apple/common/index.mdx | 32 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/docs/platforms/apple/common/index.mdx b/docs/platforms/apple/common/index.mdx index 865aa81806af0..224af11bf9520 100644 --- a/docs/platforms/apple/common/index.mdx +++ b/docs/platforms/apple/common/index.mdx @@ -311,6 +311,31 @@ func applicationDidFinishLaunching() { ``` + + +## Uncaught NSExceptions + +On macOS, the Sentry Apple SDK can't capture uncaught exceptions out of the box, therefore we recommend enabling `enableUncaughtNSExceptionReporting` in your `SentryOptions`. Alternatively, you can use the `SentryCrashExceptionApplication` class. Please visit capturing uncaught exceptions for more information. + +```swift {tabTitle:Swift} +import Sentry + +SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.enableUncaughtNSExceptionReporting = true +} +``` +```objc {tabTitle:Objective-C} +@import Sentry; + +[SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.enableUncaughtNSExceptionReporting = YES; +}]; +``` + + + ## Verify Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes. @@ -342,13 +367,6 @@ if (error) { } ``` - - -## Uncaught Exceptions - -On macOS, the Sentry Apple SDK can't capture uncaught exceptions out of the box. Please visit capturing uncaught exceptions for more information. - - ## Next Steps