Swift Package Manager (SPM)
Swift Package Manager is a powerful tool for managing dependencies in Swift that allows developers to enjoy a more native integration experience with Xcode. If you already use Swift Package Manager or prefer it over other package managers on Apple platforms, this guide will show you how to install the Kotlin Multiplatform SDK using Swift Package Manager. However, we recommend installing our SDK with Cocoapods because it currently has the best compatibility with Kotlin Multiplatform.
Prerequisites
Ensure compatibility in Kotlin Multiplatform projects targeting Cocoa by using the version of the Cocoa SDK specified in our Cocoa SDK Version Compatibility Table.
Export framework statically
Make sure your Kotlin Multiplatform framework is exported as a static framework by adding isStatic = true
Install
Add the Sentry Cocoa SDK as a package in Xcode in your iOS app via File > Add Packages. Enter the Git repo URL in the search field:
https://github.com/getsentry/sentry-cocoa.git
Define your dependency rule to have the exact version 8.17.2
and then click the "Add Package" button.
Alternatively, if your
Package.swift
file to manage dependencies, you can specify the target with:
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.17.2"),
Next, install the Kotlin Multiplatform SDK and setup your Apple targets by adding the following to your build.gradle.kts
file in your shared module:
shared/build.gradle.kts
repositories {
mavenCentral()
}
kotlin {
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true // currently available only as static framework
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.sentry:sentry-kotlin-multiplatform:0.4.0")
}
}
// Apple targets:
val iosMain by getting {
dependsOn(commonMain)
}
// Other targets...
}
}
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").
- Package:
- maven:io.sentry:sentry-kotlin-multiplatform
- Version:
- 0.4.0
- Repository:
- https://github.com/getsentry/sentry-kotlin-multiplatform