---
title: "Manual Setup"
description: "Learn how to manually set up the SDK."
url: https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/manual-setup/
---

# Manual Setup for Kotlin Multiplatform

If you can't (or prefer not to) use the [gradle plugin](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform.md#install), you can follow the instructions below to configure your application manually.

## [Install](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/manual-setup.md#install)

Sentry captures data by using an SDK within your application’s runtime.

To install the Kotlin Multiplatform SDK, you need to add the following to your `build.gradle.kts` file in your shared module. For Apple targets, this installs the Sentry Cocoa SDK with Kotlin's official [SwiftPM import](https://kotlinlang.org/docs/multiplatform/multiplatform-spm-import.html), which requires Kotlin 2.4 or newer:

```kotlin
plugins {
  kotlin("multiplatform")
  // .. your other plugins
}

kotlin {
  androidTarget()
  iosArm64()
  iosSimulatorArm64()

  sourceSets {
    commonMain.dependencies {
      implementation("io.sentry:sentry-kotlin-multiplatform:0.28.0")
    }
  }

  swiftPMDependencies {
    swiftPackage(
      url = url("https://github.com/getsentry/sentry-cocoa.git"),
      // Use the exact version from the Cocoa SDK version compatibility table.
      version = exact("9.29.2"),
      products = listOf(product("Sentry")),
    )
    // Only if you target macOS or tvOS. Use a higher version if your app needs it.
    macosMinimumDeploymentTarget.set("12.0")
    tvosMinimumDeploymentTarget.set("15.0")
  }
}
```

Make sure the Sentry Cocoa SDK version matches the one listed for your Kotlin Multiplatform SDK version in the [version compatibility table](https://github.com/getsentry/sentry-kotlin-multiplatform?tab=readme-ov-file#cocoa-sdk-version-compatibility-table).

Then run Kotlin's one-time [Xcode linkage package setup](https://kotlinlang.org/docs/multiplatform/multiplatform-spm-import.html#run-the-swiftpm-integration-task) so Xcode links the Sentry Cocoa SDK into your app.

Starting with version `0.28.0`, the SDK requires iOS 15, tvOS 15, macOS 12, or watchOS 9 or newer, and no longer supports installing the Sentry Cocoa SDK with CocoaPods.

## [Configure](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/manual-setup.md#configure)

Configuration should happen as early as possible in your application's lifecycle.

**\[commonMain] SentrySetup.kt**

```kotlin
import io.sentry.kotlin.multiplatform.Sentry

fun initializeSentry() {
  Sentry.init { options ->
    options.dsn = "https://<key>@o<orgId>.ingest.sentry.io/<projectId>"
    // Adds request headers and IP for users, for more info visit:
    // https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/data-collected/
    options.sendDefaultPii = true
  }
}
```

**iosApp**

```swift
import shared

func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
    SentrySetupKt.initializeSentry()
    return true
}

// OR if you're using SwiftUI:

@main
struct SwiftUIApp: App {
    init() {
        SentrySetupKt.initializeSentry()
    }
}
```

**\[androidApp] MainActivity.kt**

```kotlin
import your.kmp.app.initializeSentry

class YourApplication : Application() {
  override fun onCreate() {
    super.onCreate()
      initializeSentry()
   }
}
```

## [Verify](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/manual-setup.md#verify)

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

```kotlin
import io.sentry.kotlin.multiplatform.Sentry

fun captureError() {
  try {
    throw Exception("This is a test.")
  } catch (e: Exception) {
    Sentry.captureException(e)
  }
}
```

Learn more about manually capturing an error or message in our [Usage documentation](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/usage.md).

To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
