---
title: "macOS"
description: "Learn how to use Sentry's Apple SDK to automatically report errors and exceptions in your application."
url: https://docs.sentry.io/platforms/apple/guides/macos/
---

# macOS | Sentry for 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.

## [Features](https://docs.sentry.io/platforms/apple/guides/macos.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/explore/profiling.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## [Install](https://docs.sentry.io/platforms/apple/guides/macos.md#install)

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Session Replay\[ ]Logs

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](https://docs.sentry.io/platforms/apple/guides/macos/install.md). 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:

```bash
https://github.com/getsentry/sentry-cocoa.git
```

## [Configure](https://docs.sentry.io/platforms/apple/guides/macos.md#configure)

To capture all errors, we recommend to initialize the SDK on the main thread as soon as possible, such as in your `AppDelegate` `application:didFinishLaunchingWithOptions` method:

```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
}
```

## [Uncaught NSExceptions](https://docs.sentry.io/platforms/apple/guides/macos.md#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](https://docs.sentry.io/platforms/apple/guides/macos/usage.md#capturing-uncaught-exceptions) for more information.

```swift
import Sentry

SentrySDK.start { options in
    options.dsn = "___PUBLIC_DSN___"
    options.enableUncaughtNSExceptionReporting = true
}
```

## [Verify](https://docs.sentry.io/platforms/apple/guides/macos.md#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
import Sentry

do {
    try aMethodThatMightFail()
} catch {
    SentrySDK.capture(error: error)
}
```

## [Next Steps](https://docs.sentry.io/platforms/apple/guides/macos.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup
* [Learn more about Sentry's Apple SDK features](https://docs.sentry.io/platforms/apple/guides/macos/features.md)
* [Add readable stack traces to errors](https://docs.sentry.io/platforms/apple/guides/macos/dsym.md)
* [Add Apple Privacy manifest](https://docs.sentry.io/platforms/apple/guides/macos/data-management/apple-privacy-manifest.md)

## [FAQ](https://docs.sentry.io/platforms/apple/guides/macos.md#faq)

Can I initialize the SDK from a background thread?

Yes, you can initialize the SDK from a background thread, but this is **not recommended**. Some initialization steps, like collecting view hierarchy information, must still run on the main thread. Initializing on the main thread also ensures reliable detection of app launch crashes.

## Other Apple Frameworks

- [iOS](https://docs.sentry.io/platforms/apple/guides/ios.md)
- [tvOS](https://docs.sentry.io/platforms/apple/guides/tvos.md)
- [visionOS](https://docs.sentry.io/platforms/apple/guides/visionos.md)
- [watchOS](https://docs.sentry.io/platforms/apple/guides/watchos.md)

## Topics

- [Features](https://docs.sentry.io/platforms/apple/guides/macos/features.md)
- [Installation Methods](https://docs.sentry.io/platforms/apple/guides/macos/install.md)
- [Source Context](https://docs.sentry.io/platforms/apple/guides/macos/sourcecontext.md)
- [Extended Configuration](https://docs.sentry.io/platforms/apple/guides/macos/configuration.md)
- [Metrics](https://docs.sentry.io/platforms/apple/guides/macos/metrics.md)
- [Capturing Errors](https://docs.sentry.io/platforms/apple/guides/macos/usage.md)
- [Uploading Debug Symbols](https://docs.sentry.io/platforms/apple/guides/macos/dsym.md)
- [Integrations](https://docs.sentry.io/platforms/apple/guides/macos/integrations.md)
- [Enriching Events](https://docs.sentry.io/platforms/apple/guides/macos/enriching-events.md)
- [Data Management](https://docs.sentry.io/platforms/apple/guides/macos/data-management.md)
- [Tracing](https://docs.sentry.io/platforms/apple/guides/macos/tracing.md)
- [Profiling](https://docs.sentry.io/platforms/apple/guides/macos/profiling.md)
- [Session Replay](https://docs.sentry.io/platforms/apple/guides/macos/session-replay.md)
- [Logs](https://docs.sentry.io/platforms/apple/guides/macos/logs.md)
- [User Feedback](https://docs.sentry.io/platforms/apple/guides/macos/user-feedback.md)
- [Mobile SDK Releases](https://docs.sentry.io/platforms/apple/guides/macos/releases.md)
- [SDK Overhead](https://docs.sentry.io/platforms/apple/guides/macos/overhead.md)
- [Migration Guide](https://docs.sentry.io/platforms/apple/guides/macos/migration.md)
- [Troubleshooting](https://docs.sentry.io/platforms/apple/guides/macos/troubleshooting.md)
