From fa1bcec118fa7e1907c58c741caca7318ddaf3dc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Sep 2025 07:53:39 +0000 Subject: [PATCH 1/6] Add Apple platform guides for macOS, tvOS, visionOS, watchOS Co-authored-by: phil.niedertscheider --- docs/platforms/apple/guides/macos/index.mdx | 5 +++++ docs/platforms/apple/guides/tvos/index.mdx | 5 +++++ docs/platforms/apple/guides/visionos/index.mdx | 5 +++++ docs/platforms/apple/guides/watchos/index.mdx | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 docs/platforms/apple/guides/macos/index.mdx create mode 100644 docs/platforms/apple/guides/tvos/index.mdx create mode 100644 docs/platforms/apple/guides/visionos/index.mdx create mode 100644 docs/platforms/apple/guides/watchos/index.mdx diff --git a/docs/platforms/apple/guides/macos/index.mdx b/docs/platforms/apple/guides/macos/index.mdx new file mode 100644 index 00000000000000..52793ffa39a639 --- /dev/null +++ b/docs/platforms/apple/guides/macos/index.mdx @@ -0,0 +1,5 @@ +--- +title: macOS +--- + + \ No newline at end of file diff --git a/docs/platforms/apple/guides/tvos/index.mdx b/docs/platforms/apple/guides/tvos/index.mdx new file mode 100644 index 00000000000000..7058fcf3dc00ca --- /dev/null +++ b/docs/platforms/apple/guides/tvos/index.mdx @@ -0,0 +1,5 @@ +--- +title: tvOS +--- + + \ No newline at end of file diff --git a/docs/platforms/apple/guides/visionos/index.mdx b/docs/platforms/apple/guides/visionos/index.mdx new file mode 100644 index 00000000000000..bdb419e5ab7b3d --- /dev/null +++ b/docs/platforms/apple/guides/visionos/index.mdx @@ -0,0 +1,5 @@ +--- +title: visionOS +--- + + \ No newline at end of file diff --git a/docs/platforms/apple/guides/watchos/index.mdx b/docs/platforms/apple/guides/watchos/index.mdx new file mode 100644 index 00000000000000..ad977d8f58a894 --- /dev/null +++ b/docs/platforms/apple/guides/watchos/index.mdx @@ -0,0 +1,5 @@ +--- +title: watchOS +--- + + \ No newline at end of file From 04bfff30d9c1a1b12f2886b94ae42e0b8a3e56ff Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Sep 2025 08:40:55 +0000 Subject: [PATCH 2/6] Refactor Apple platform docs for clarity and consistency This commit updates the Apple platform documentation to improve clarity and consistency across different platforms. It refactors the content to use a more standardized structure and includes updated code examples and feature descriptions. Co-authored-by: phil.niedertscheider --- docs/platforms/apple/guides/macos/index.mdx | 428 +++++++++++++++++- docs/platforms/apple/guides/tvos/index.mdx | 428 +++++++++++++++++- .../platforms/apple/guides/visionos/index.mdx | 428 +++++++++++++++++- docs/platforms/apple/guides/watchos/index.mdx | 428 +++++++++++++++++- 4 files changed, 1708 insertions(+), 4 deletions(-) diff --git a/docs/platforms/apple/guides/macos/index.mdx b/docs/platforms/apple/guides/macos/index.mdx index 52793ffa39a639..c6279a725c993c 100644 --- a/docs/platforms/apple/guides/macos/index.mdx +++ b/docs/platforms/apple/guides/macos/index.mdx @@ -2,4 +2,430 @@ title: macOS --- - \ No newline at end of file +On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. + + + +If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. + + + + + + + +The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. + + + + + +## Features + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + + + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). + + + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + +## Install + + + + + + + + + + + + + + +Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. + + + +We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: + +``` +https://github.com/getsentry/sentry-cocoa.git +``` + + + + +We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: + +```bash +brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios +``` + +This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. +If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). + + + +- Install the Sentry SDK via Swift Package Manager or Cocoapods +- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error +- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script +- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) +- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added + + + + + +## Configure + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: + + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0; + options.sessionReplay.sessionSampleRate = 0.1; + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + + // ___PRODUCT_OPTION_START___ performance + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + + // ___PRODUCT_OPTION_START___ profiling + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: + +```swift +import Sentry + +func applicationDidFinishLaunching() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } +} +``` + + + + +## 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. + + + +To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. + + + +```swift {tabTitle:Swift} +import Sentry + +do { + try aMethodThatMightFail() +} catch { + SentrySDK.capture(error: error) +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +NSError *error = nil; +[self aMethodThatMightFail:&error] + +if (error) { + [SentrySDK captureError:error]; +} +``` + + +## Next Steps + +- Learn more about Sentry's Apple SDK features +- Add readable stack traces to errors +- Add Apple Privacy manifest \ No newline at end of file diff --git a/docs/platforms/apple/guides/tvos/index.mdx b/docs/platforms/apple/guides/tvos/index.mdx index 7058fcf3dc00ca..a764c9ef323f6b 100644 --- a/docs/platforms/apple/guides/tvos/index.mdx +++ b/docs/platforms/apple/guides/tvos/index.mdx @@ -2,4 +2,430 @@ title: tvOS --- - \ No newline at end of file +On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. + + + +If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. + + + + + + + +The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. + + + + + +## Features + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + + + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). + + + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + +## Install + + + + + + + + + + + + + + +Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. + + + +We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: + +``` +https://github.com/getsentry/sentry-cocoa.git +``` + + + + +We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: + +```bash +brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios +``` + +This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. +If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). + + + +- Install the Sentry SDK via Swift Package Manager or Cocoapods +- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error +- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script +- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) +- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added + + + + + +## Configure + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: + + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0; + options.sessionReplay.sessionSampleRate = 0.1; + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + + // ___PRODUCT_OPTION_START___ performance + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + + // ___PRODUCT_OPTION_START___ profiling + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: + +```swift +import Sentry + +func applicationDidFinishLaunching() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } +} +``` + + + + +## 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. + + + +To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. + + + +```swift {tabTitle:Swift} +import Sentry + +do { + try aMethodThatMightFail() +} catch { + SentrySDK.capture(error: error) +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +NSError *error = nil; +[self aMethodThatMightFail:&error] + +if (error) { + [SentrySDK captureError:error]; +} +``` + + +## Next Steps + +- Learn more about Sentry's Apple SDK features +- Add readable stack traces to errors +- Add Apple Privacy manifest \ No newline at end of file diff --git a/docs/platforms/apple/guides/visionos/index.mdx b/docs/platforms/apple/guides/visionos/index.mdx index bdb419e5ab7b3d..c43b54ca037edb 100644 --- a/docs/platforms/apple/guides/visionos/index.mdx +++ b/docs/platforms/apple/guides/visionos/index.mdx @@ -2,4 +2,430 @@ title: visionOS --- - \ No newline at end of file +On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. + + + +If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. + + + + + + + +The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. + + + + + +## Features + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + + + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). + + + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + +## Install + + + + + + + + + + + + + + +Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. + + + +We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: + +``` +https://github.com/getsentry/sentry-cocoa.git +``` + + + + +We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: + +```bash +brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios +``` + +This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. +If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). + + + +- Install the Sentry SDK via Swift Package Manager or Cocoapods +- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error +- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script +- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) +- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added + + + + + +## Configure + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: + + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0; + options.sessionReplay.sessionSampleRate = 0.1; + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + + // ___PRODUCT_OPTION_START___ performance + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + + // ___PRODUCT_OPTION_START___ profiling + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: + +```swift +import Sentry + +func applicationDidFinishLaunching() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } +} +``` + + + + +## 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. + + + +To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. + + + +```swift {tabTitle:Swift} +import Sentry + +do { + try aMethodThatMightFail() +} catch { + SentrySDK.capture(error: error) +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +NSError *error = nil; +[self aMethodThatMightFail:&error] + +if (error) { + [SentrySDK captureError:error]; +} +``` + + +## Next Steps + +- Learn more about Sentry's Apple SDK features +- Add readable stack traces to errors +- Add Apple Privacy manifest \ No newline at end of file diff --git a/docs/platforms/apple/guides/watchos/index.mdx b/docs/platforms/apple/guides/watchos/index.mdx index ad977d8f58a894..899dc9b1e51980 100644 --- a/docs/platforms/apple/guides/watchos/index.mdx +++ b/docs/platforms/apple/guides/watchos/index.mdx @@ -2,4 +2,430 @@ title: watchOS --- - \ No newline at end of file +On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. + + + +If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. + + + + + + + +The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. + + + + + +## Features + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + + + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). + + + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + +## Install + + + + + + + + + + + + + + +Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. + + + +We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: + +``` +https://github.com/getsentry/sentry-cocoa.git +``` + + + + +We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: + +```bash +brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios +``` + +This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. +If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). + + + +- Install the Sentry SDK via Swift Package Manager or Cocoapods +- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error +- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script +- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) +- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added + + + + + +## Configure + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: + + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0; + options.sessionReplay.sessionSampleRate = 0.1; + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + + // ___PRODUCT_OPTION_START___ performance + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + + // ___PRODUCT_OPTION_START___ profiling + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: + +```swift +import Sentry + +func applicationDidFinishLaunching() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } +} +``` + + + + +## 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. + + + +To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. + + + +```swift {tabTitle:Swift} +import Sentry + +do { + try aMethodThatMightFail() +} catch { + SentrySDK.capture(error: error) +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +NSError *error = nil; +[self aMethodThatMightFail:&error] + +if (error) { + [SentrySDK captureError:error]; +} +``` + + +## Next Steps + +- Learn more about Sentry's Apple SDK features +- Add readable stack traces to errors +- Add Apple Privacy manifest \ No newline at end of file From bc54f7d99131ee36e9633e7ae5d9c428550d27a7 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 23 Sep 2025 10:51:15 +0200 Subject: [PATCH 3/6] convert to includes --- docs/platforms/apple/guides/macos/index.mdx | 428 +----------------- docs/platforms/apple/guides/tvos/index.mdx | 428 +----------------- .../platforms/apple/guides/visionos/index.mdx | 428 +----------------- docs/platforms/apple/guides/watchos/index.mdx | 428 +----------------- includes/apple-platform-getting-started.mdx | 427 +++++++++++++++++ 5 files changed, 431 insertions(+), 1708 deletions(-) create mode 100644 includes/apple-platform-getting-started.mdx diff --git a/docs/platforms/apple/guides/macos/index.mdx b/docs/platforms/apple/guides/macos/index.mdx index c6279a725c993c..04bea042cad58b 100644 --- a/docs/platforms/apple/guides/macos/index.mdx +++ b/docs/platforms/apple/guides/macos/index.mdx @@ -2,430 +2,4 @@ title: macOS --- -On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. - - - -If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. - - - - - - - -The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. - - - - - -## Features - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). - - - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - - - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - -## Install - - - - - - - - - - - - - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. - - - -We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: - -``` -https://github.com/getsentry/sentry-cocoa.git -``` - - - - -We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: - -```bash -brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios -``` - -This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. -If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). - - - -- Install the Sentry SDK via Swift Package Manager or Cocoapods -- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error -- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script -- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) -- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added - - - - - -## Configure - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: - - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0; - options.sessionReplay.sessionSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - - // ___PRODUCT_OPTION_START___ logs - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - - // ___PRODUCT_OPTION_START___ profiling - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: - -```swift -import Sentry - -func applicationDidFinishLaunching() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } -} -``` - - - - -## 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. - - - -To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. - - - -```swift {tabTitle:Swift} -import Sentry - -do { - try aMethodThatMightFail() -} catch { - SentrySDK.capture(error: error) -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -NSError *error = nil; -[self aMethodThatMightFail:&error] - -if (error) { - [SentrySDK captureError:error]; -} -``` - - -## Next Steps - -- Learn more about Sentry's Apple SDK features -- Add readable stack traces to errors -- Add Apple Privacy manifest \ No newline at end of file + diff --git a/docs/platforms/apple/guides/tvos/index.mdx b/docs/platforms/apple/guides/tvos/index.mdx index a764c9ef323f6b..8f26e0cf60a52f 100644 --- a/docs/platforms/apple/guides/tvos/index.mdx +++ b/docs/platforms/apple/guides/tvos/index.mdx @@ -2,430 +2,4 @@ title: tvOS --- -On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. - - - -If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. - - - - - - - -The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. - - - - - -## Features - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). - - - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - - - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - -## Install - - - - - - - - - - - - - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. - - - -We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: - -``` -https://github.com/getsentry/sentry-cocoa.git -``` - - - - -We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: - -```bash -brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios -``` - -This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. -If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). - - - -- Install the Sentry SDK via Swift Package Manager or Cocoapods -- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error -- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script -- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) -- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added - - - - - -## Configure - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: - - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0; - options.sessionReplay.sessionSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - - // ___PRODUCT_OPTION_START___ logs - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - - // ___PRODUCT_OPTION_START___ profiling - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: - -```swift -import Sentry - -func applicationDidFinishLaunching() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } -} -``` - - - - -## 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. - - - -To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. - - - -```swift {tabTitle:Swift} -import Sentry - -do { - try aMethodThatMightFail() -} catch { - SentrySDK.capture(error: error) -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -NSError *error = nil; -[self aMethodThatMightFail:&error] - -if (error) { - [SentrySDK captureError:error]; -} -``` - - -## Next Steps - -- Learn more about Sentry's Apple SDK features -- Add readable stack traces to errors -- Add Apple Privacy manifest \ No newline at end of file + diff --git a/docs/platforms/apple/guides/visionos/index.mdx b/docs/platforms/apple/guides/visionos/index.mdx index c43b54ca037edb..d1db2d0fcb483c 100644 --- a/docs/platforms/apple/guides/visionos/index.mdx +++ b/docs/platforms/apple/guides/visionos/index.mdx @@ -2,430 +2,4 @@ title: visionOS --- -On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. - - - -If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. - - - - - - - -The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. - - - - - -## Features - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). - - - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - - - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - -## Install - - - - - - - - - - - - - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. - - - -We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: - -``` -https://github.com/getsentry/sentry-cocoa.git -``` - - - - -We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: - -```bash -brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios -``` - -This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. -If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). - - - -- Install the Sentry SDK via Swift Package Manager or Cocoapods -- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error -- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script -- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) -- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added - - - - - -## Configure - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: - - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0; - options.sessionReplay.sessionSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - - // ___PRODUCT_OPTION_START___ logs - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - - // ___PRODUCT_OPTION_START___ profiling - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: - -```swift -import Sentry - -func applicationDidFinishLaunching() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } -} -``` - - - - -## 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. - - - -To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. - - - -```swift {tabTitle:Swift} -import Sentry - -do { - try aMethodThatMightFail() -} catch { - SentrySDK.capture(error: error) -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -NSError *error = nil; -[self aMethodThatMightFail:&error] - -if (error) { - [SentrySDK captureError:error]; -} -``` - - -## Next Steps - -- Learn more about Sentry's Apple SDK features -- Add readable stack traces to errors -- Add Apple Privacy manifest \ No newline at end of file + diff --git a/docs/platforms/apple/guides/watchos/index.mdx b/docs/platforms/apple/guides/watchos/index.mdx index 899dc9b1e51980..4b28ccffe40769 100644 --- a/docs/platforms/apple/guides/watchos/index.mdx +++ b/docs/platforms/apple/guides/watchos/index.mdx @@ -2,430 +2,4 @@ title: watchOS --- -On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. - - - -If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. - - - - - - - -The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. - - - - - -## Features - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). - - - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - - - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - -## Install - - - - - - - - - - - - - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. - - - -We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: - -``` -https://github.com/getsentry/sentry-cocoa.git -``` - - - - -We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: - -```bash -brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios -``` - -This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. -If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). - - - -- Install the Sentry SDK via Swift Package Manager or Cocoapods -- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error -- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script -- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) -- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added - - - - - -## Configure - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: - - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0; - options.sessionReplay.sessionSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - - // ___PRODUCT_OPTION_START___ logs - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - - // ___PRODUCT_OPTION_START___ profiling - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: - -```swift -import Sentry - -func applicationDidFinishLaunching() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } -} -``` - - - - -## 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. - - - -To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. - - - -```swift {tabTitle:Swift} -import Sentry - -do { - try aMethodThatMightFail() -} catch { - SentrySDK.capture(error: error) -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -NSError *error = nil; -[self aMethodThatMightFail:&error] - -if (error) { - [SentrySDK captureError:error]; -} -``` - - -## Next Steps - -- Learn more about Sentry's Apple SDK features -- Add readable stack traces to errors -- Add Apple Privacy manifest \ No newline at end of file + diff --git a/includes/apple-platform-getting-started.mdx b/includes/apple-platform-getting-started.mdx new file mode 100644 index 00000000000000..efe61f05418b60 --- /dev/null +++ b/includes/apple-platform-getting-started.mdx @@ -0,0 +1,427 @@ +On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. + + + +If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. + + + + + + + +The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. + + + + + +## Features + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). + + + + + +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). + + + +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. + +## Install + + + + + + + + + + + + + + +Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. + + + +We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: + +``` +https://github.com/getsentry/sentry-cocoa.git +``` + + + + +We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: + +```bash +brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios +``` + +This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. +If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). + + + +- Install the Sentry SDK via Swift Package Manager or Cocoapods +- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error +- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script +- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) +- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added + + + + + +## Configure + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: + + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0; + options.sessionReplay.sessionSampleRate = 0.1; + // ___PRODUCT_OPTION_END___ session-replay + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ session-replay + // Record session replays for 100% of errors and 10% of sessions + options.sessionReplay.onErrorSampleRate = 1.0 + options.sessionReplay.sessionSampleRate = 0.1 + // ___PRODUCT_OPTION_END___ session-replay + + // ___PRODUCT_OPTION_START___ logs + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + +```swift {tabTitle:Swift} +import Sentry + +func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + + return true +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"___PUBLIC_DSN___"; + options.debug = YES; // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = YES; + + // ___PRODUCT_OPTION_START___ performance + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = @1.f; + // ___PRODUCT_OPTION_END___ performance + + // ___PRODUCT_OPTION_START___ profiling + options.configureProfiling = ^(SentryProfileOptions *profiling) { + profiling.lifecycle = SentryProfileLifecycleTrace; + profiling.sessionSampleRate = 1.f; + }; + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = YES; + // ___PRODUCT_OPTION_END___ logs + }]; + + return YES; +} +``` + +```swift {tabTitle:SwiftUI with App conformer} +import Sentry + +@main +struct SwiftUIApp: App { + init() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + options.configureProfiling = { + $0.lifecycle = .trace + $0.sessionSampleRate = 1 + } + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } + } +} +``` + + + + + + +To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: + +```swift +import Sentry + +func applicationDidFinishLaunching() { + SentrySDK.start { options in + options.dsn = "___PUBLIC_DSN___" + options.debug = true // Enabled debug when first installing is always helpful + + // Adds IP for users. + // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ + options.sendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.experimental.enableLogs = true + // ___PRODUCT_OPTION_END___ logs + } +} +``` + + + + +## 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. + + + +To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. + + + +```swift {tabTitle:Swift} +import Sentry + +do { + try aMethodThatMightFail() +} catch { + SentrySDK.capture(error: error) +} +``` + +```objc {tabTitle:Objective-C} +@import Sentry; + +NSError *error = nil; +[self aMethodThatMightFail:&error] + +if (error) { + [SentrySDK captureError:error]; +} +``` + + +## Next Steps + +- Learn more about Sentry's Apple SDK features +- Add readable stack traces to errors +- Add Apple Privacy manifest From 9f50ae8a641623f50b37d0d57974e25b2fb4fdb5 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Tue, 23 Sep 2025 10:19:29 -0700 Subject: [PATCH 4/6] adding in iOS title and descriptions for each page --- docs/platforms/apple/common/index.mdx | 6 ++++++ docs/platforms/apple/guides/macos/index.mdx | 1 + docs/platforms/apple/guides/tvos/index.mdx | 1 + docs/platforms/apple/guides/visionos/index.mdx | 1 + docs/platforms/apple/guides/watchos/index.mdx | 1 + 5 files changed, 10 insertions(+) diff --git a/docs/platforms/apple/common/index.mdx b/docs/platforms/apple/common/index.mdx index efe61f05418b60..977dff0cbc4b54 100644 --- a/docs/platforms/apple/common/index.mdx +++ b/docs/platforms/apple/common/index.mdx @@ -1,3 +1,9 @@ +--- +title: iOS +sidebar_order: 10 +description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. +--- + On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. diff --git a/docs/platforms/apple/guides/macos/index.mdx b/docs/platforms/apple/guides/macos/index.mdx index 04bea042cad58b..a4cb3900571fd1 100644 --- a/docs/platforms/apple/guides/macos/index.mdx +++ b/docs/platforms/apple/guides/macos/index.mdx @@ -1,5 +1,6 @@ --- title: macOS +description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. --- diff --git a/docs/platforms/apple/guides/tvos/index.mdx b/docs/platforms/apple/guides/tvos/index.mdx index 8f26e0cf60a52f..bbf9358c1f3170 100644 --- a/docs/platforms/apple/guides/tvos/index.mdx +++ b/docs/platforms/apple/guides/tvos/index.mdx @@ -1,5 +1,6 @@ --- title: tvOS +description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. --- diff --git a/docs/platforms/apple/guides/visionos/index.mdx b/docs/platforms/apple/guides/visionos/index.mdx index d1db2d0fcb483c..66dbfc114e7cf2 100644 --- a/docs/platforms/apple/guides/visionos/index.mdx +++ b/docs/platforms/apple/guides/visionos/index.mdx @@ -1,5 +1,6 @@ --- title: visionOS +description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. --- diff --git a/docs/platforms/apple/guides/watchos/index.mdx b/docs/platforms/apple/guides/watchos/index.mdx index 4b28ccffe40769..4b137a6dbab885 100644 --- a/docs/platforms/apple/guides/watchos/index.mdx +++ b/docs/platforms/apple/guides/watchos/index.mdx @@ -1,5 +1,6 @@ --- title: watchOS +description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. --- From 03e269aecef71ae7602a261e26da88c50dc0e856 Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Thu, 25 Sep 2025 11:11:07 -0700 Subject: [PATCH 5/6] Update docs/platforms/apple/common/index.mdx Co-authored-by: Philipp Hofmann --- docs/platforms/apple/common/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/apple/common/index.mdx b/docs/platforms/apple/common/index.mdx index 977dff0cbc4b54..f6ff45b526b8a4 100644 --- a/docs/platforms/apple/common/index.mdx +++ b/docs/platforms/apple/common/index.mdx @@ -1,7 +1,7 @@ --- title: iOS sidebar_order: 10 -description: Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application. +description: Learn how to use Sentry's Apple SDK to automatically report errors, crashes, watchdog terminations, and app hangs in your application. --- On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. From 0a169ecd9c03d076387a3faa4329a87dac4863a3 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Fri, 26 Sep 2025 13:17:32 +0200 Subject: [PATCH 6/6] use include in common page --- docs/platforms/apple/common/index.mdx | 428 +------------------------- 1 file changed, 1 insertion(+), 427 deletions(-) diff --git a/docs/platforms/apple/common/index.mdx b/docs/platforms/apple/common/index.mdx index f6ff45b526b8a4..2e9b0c775e3315 100644 --- a/docs/platforms/apple/common/index.mdx +++ b/docs/platforms/apple/common/index.mdx @@ -4,430 +4,4 @@ sidebar_order: 10 description: Learn how to use Sentry's Apple SDK to automatically report errors, crashes, watchdog terminations, and app hangs in your application. --- -On this page, we get you up and running with Sentry's Apple SDK, which will automatically report errors and exceptions in your application. - - - -If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page. - - - - - - - -The support for [visionOS](https://developer.apple.com/visionos/) is currently experimental, which means it may have bugs. We recognize the irony. - - - - - -## Features - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). - - - - - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - - - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - -## Install - - - - - - - - - - - - - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. - - - -We recommend installing the SDK with Swift Package Manager (SPM), but we also support alternate [installation methods](install/). To integrate Sentry into your Xcode project, open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field: - -``` -https://github.com/getsentry/sentry-cocoa.git -``` - - - - -We recommend installing the SDK through our [Sentry Wizard](https://github.com/getsentry/sentry-wizard) by running the following command inside your project directory: - -```bash -brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios -``` - -This will patch your project and configure the SDK. You'll only need to patch the project once, then you'll be able to add the patched files to your version control system. -If you prefer, you can also [set up the SDK manually](/platforms/apple/guides/ios/manual-setup/) or follow the instructions below to adapt the [configuration](#configure). - - - -- Install the Sentry SDK via Swift Package Manager or Cocoapods -- Update your `AppDelegate` or SwiftUI App Initializer with the default Sentry configuration and an example error -- Add a new `Upload Debug Symbols` phase to your `xcodebuild` build script -- Create `.sentryclirc` with an auth token to upload debug symbols (this file is automatically added to `.gitignore`) -- If you're using Fastlane, a lane for uploading debug symbols to Sentry will be added - - - - - -## Configure - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method: - - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0; - options.sessionReplay.sessionSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ session-replay - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ session-replay - // Record session replays for 100% of errors and 10% of sessions - options.sessionReplay.onErrorSampleRate = 1.0 - options.sessionReplay.sessionSampleRate = 0.1 - // ___PRODUCT_OPTION_END___ session-replay - - // ___PRODUCT_OPTION_START___ logs - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - -```swift {tabTitle:Swift} -import Sentry - -func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - - return true -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { - options.dsn = @"___PUBLIC_DSN___"; - options.debug = YES; // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = YES; - - // ___PRODUCT_OPTION_START___ performance - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = @1.f; - // ___PRODUCT_OPTION_END___ performance - - // ___PRODUCT_OPTION_START___ profiling - options.configureProfiling = ^(SentryProfileOptions *profiling) { - profiling.lifecycle = SentryProfileLifecycleTrace; - profiling.sessionSampleRate = 1.f; - }; - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = YES; - // ___PRODUCT_OPTION_END___ logs - }]; - - return YES; -} -``` - -```swift {tabTitle:SwiftUI with App conformer} -import Sentry - -@main -struct SwiftUIApp: App { - init() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - - options.configureProfiling = { - $0.lifecycle = .trace - $0.sessionSampleRate = 1 - } - // ___PRODUCT_OPTION_END___ profiling - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } - } -} -``` - - - - - - -To capture all errors, initialize the SDK as soon as possible, such as in your `WKExtensionDelegate.applicationDidFinishLaunching` method: - -```swift -import Sentry - -func applicationDidFinishLaunching() { - SentrySDK.start { options in - options.dsn = "___PUBLIC_DSN___" - options.debug = true // Enabled debug when first installing is always helpful - - // Adds IP for users. - // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ - options.sendDefaultPii = true - // ___PRODUCT_OPTION_START___ performance - - // Set tracesSampleRate to 1 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.tracesSampleRate = 1 - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ logs - - // Enable logs to be sent to Sentry - options.experimental.enableLogs = true - // ___PRODUCT_OPTION_END___ logs - } -} -``` - - - - -## 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. - - - -To verify crashes, ensure you run your application without a debugger attached. Otherwise, the SDK won't capture the crash. - - - -```swift {tabTitle:Swift} -import Sentry - -do { - try aMethodThatMightFail() -} catch { - SentrySDK.capture(error: error) -} -``` - -```objc {tabTitle:Objective-C} -@import Sentry; - -NSError *error = nil; -[self aMethodThatMightFail:&error] - -if (error) { - [SentrySDK captureError:error]; -} -``` - - -## Next Steps - -- Learn more about Sentry's Apple SDK features -- Add readable stack traces to errors -- Add Apple Privacy manifest +