Manual Setup

Learn how to set up the SDK manually.

If you can't (or prefer not to) run the automatic setup, you can follow the instructions below to configure your application manually.

The minimum required version for iOS is 11.0.

We recommend installing the SDK with SPM, but we also support alternate installation methods. To integrate Sentry into your Xcode project, add the package using the Github URL:

Copied
https://github.com/getsentry/sentry-cocoa.git

The Package has a few products you can depend on, but the recommended one is Sentry. For more details see the full docs on using Swift Package Manager.

We recommend initializing the SDK on the main thread as soon as possible – in your AppDelegate application:didFinishLaunchingWithOptions method, for example:

Copied
import Sentry // Make sure you 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

        // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
        // We recommend adjusting this value in production.
        options.tracesSampleRate = 1.0
    }

    return true
}

If you're using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the App conformer's initializer:

Copied
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

            // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
            // We recommend adjusting this value in production.
            options.tracesSampleRate = 1.0
        }
    }
}
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").