macOS

Installation

We recommend installing the SDK with CocoaPods. To integrate Sentry into your Xcode project, specify it in your Podfile:

Podfile
Copied
platform :macos, '8.0'
use_frameworks! # This is important

target 'YourApp' do
  pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '5.2.2'
end

Afterwards run pod install.

For other installation methods, please see our documentation.

Configuration

Initialize the SDK as soon as possible in your application lifecycle, such as in your AppDelegate application:didFinishLaunchingWithOptions method:

Copied
import Sentry // Make sure you import Sentry

// ....

func application(_ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    SentrySDK.start { options in
        options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
        options.debug = true // Enabled debug when first installing is always helpful
        options.enableAutoSessionTracking = true // Enable session tracking
    }

    return true
}

Debug Symbols

Before capturing crashes, you need to provide debug information to Sentry. Debug information is provided by uploading dSYM files using one of two methods, dependent on your setup:

Verify

To validate that the SDK is correctly set up and connected to your Sentry project, capture a test message:

Copied
SentrySDK.capture(message: "My first test message")

If everything is working correctly, this message should appear within seconds in your Sentry project.

Crash Handling

Our SDK hooks into all signal and exception handlers, except for MacOS. If you are using MacOS, please see the additional step provided in Advanced Usage To try it out, the SDK provides a test crash function:

Copied
SentrySDK.crash()

If you crash with a debugger attached, nothing will happen.

Crashes are submitted only upon re-launch of the application. To view the crash in Sentry, close your app and re-launch it.

You can edit this page on GitHub.
Package:
cocoapods:sentry-cocoa
Version:
5.2.2
Repository:
https://github.com/getsentry/sentry-cocoa