Skip to content
Codeskop

Kotlin Multiplatform & iOS (beta)

Report crashes and errors from shared Kotlin code, and monitor your iOS app through the same SDK.

Early access beta

Kotlin Multiplatform and iOS support is in beta. The core is the same SDK that powers our Android and Flutter releases, but the setup and API may still change before general availability. Contact us to join the beta.

What the beta covers

  • Shared code (commonMain): identify, reset, recordException, setEnabled and flush work from shared Kotlin.
  • Android target: everything in the Android SDK: crashes, ANRs, and OkHttp network capture.
  • iOS: uncaught exceptions and crash signals are captured automatically once the SDK starts, with the same on-device queue as Android. iOS 14 or later.

Not in the beta yet

There's no Ktor client plugin, so network capture from shared code isn't automatic. On iOS, URLSession requests aren't captured automatically either. See iOS network capture below.

Kotlin Multiplatform setup

Add the shared core to commonMain and the Android runtime to androidMain:

shared/build.gradle.kts
kotlin {    sourceSets {        commonMain.dependencies {            implementation("com.codeskop.sdk:tracker-core:0.3.0")        }        androidMain.dependencies {            implementation("com.codeskop.sdk:tracker-android:0.3.0")            implementation("com.codeskop.sdk:tracker-okhttp:0.3.0") // optional network capture        }    }}

Initialize on each platform, then call the SDK from shared code:

androidMain
// androidMain: initialize once, e.g. in Application.onCreateCodeskopAndroid.init(    context,    CodeskopConfig(apiKey = BuildConfig.CODESKOP_KEY),)
commonMain
// commonMain: identify and report from shared codeCodeskop.identify(userId = user.id) try {    syncCart()} catch (e: Exception) {    Codeskop.recordException(e)}

The Android side behaves exactly like the Android SDK, including initialization from the manifest instead of code.

iOS setup

1. Add the Swift package

During the beta, the iOS SDK is distributed as a Swift package from a private repository. We'll give your team access when you join the beta. Then add it in Xcode or Package.swift and add the CodeskopSDK product to your app target:

Package.swift
.package(url: "https://github.com/Codeskop-io/mobile-sdk.git", from: "0.3.0")

2. Start the SDK and identify users

Call start once at launch, for example in your AppDelegate or App initializer. It returns immediately and does its setup in the background.

AppDelegate.swift
import CodeskopSDK // Swift needs every CodeskopConfig parameter spelled outlet config = CodeskopConfig(    apiKey: "cs_live_pk_xxx",    endpoint: "https://api.codeskop.com",    environment: "production",    sampleRates: [:],    captureNetwork: true,    captureHeaders: true,    captureBodies: false,    redactHeaders: ["authorization", "cookie", "set-cookie"],    redactQueryKeys: ["token", "apikey", "password", "secret"],    maxQueueMb: 10,    heartbeatEnabled: true,    flushBatchSize: 50)CodeskopIos.shared.start(config: config) // At loginCodeskop.shared.identify(userId: user.id, traits: [:])

Why every parameter?

Kotlin's default values don't carry over to the generated Swift initializer, so each CodeskopConfig field has to be passed. Use the values above as your defaults; they match the Android defaults. See configuration for what each one does.

iOS network capture

To report failing requests on iOS, register a small URLProtocol subclass in your app that forwards failures to Codeskop.shared.captureApiError(call:). We share a reference implementation with beta teams. It's under 100 lines you copy into your project.

Next steps