Crash reporting for KMP apps

The Apptics KMP SDK provides comprehensive crash tracking and reporting for Kotlin Multiplatform applications on iOS platforms. It automatically captures unhandled Kotlin exceptions, converts them to iOS-compatible NSException format, and integrates seamlessly with the Apptics crash reporting system.

Compatibility and prerequisites

Prerequisites

  • Android Studio Hedgehog (2023.1.1) or newer
  • AndroidX enabled
  • Android minSdk 24 (effective floor; analytics alone compiles against minSdk 22), compileSdk 35
  • JDK 17 to run the Gradle build (the crash module compiles its own bytecode with jvmToolchain(11) and consumers only need JDK 17 for the build)
  • Gradle 8.9 (wrapper-provided; 8.0+ required)
  • Native iOS applications using Kotlin/Native
  • iOS 16.0+ deployment target (arm64, simulator arm64, x64)
  • Kotlin 2.0.20+ in the consuming project

Compatibility matrix

Apptics KMP SDKapptics-pluginAGPKotliniOS target
0.1-beta0.2.38.1.42.0.2016.0

Module versions in 0.1-beta

Copied`com.zoho.apptics.kmp:analytics:0.1-beta`
`com.zoho.apptics.kmp:crash:0.1-beta`

Note: 

  • The shared module's minSdk(24) is the effective floor for Android consumers even though analytics alone compiles against minSdk 22.
  • The crash module uses jvmToolchain(11) for its own bytecode; this does not require consumers to run on JDK 11 as it only affects the class file format of crash module classes.

Quick start

Android crash tracking integration

Android crash tracking for KMP works the same way it works for Android. Follow the steps mentioned in the Android crash reporting guide.

iOS crash tracking integration

 1. Prerequisites 

Integrate Apptics iOS SDK with your iOS application. Follow the steps mentioned in the iOS crash reporting guide.

2. Add the KMP SDK dependency

You can choose one of the following approaches based on your project setup.

Option A - Using Cocoapods

Copiedkotlin {
    cocoapods {
        summary = "Your Shared Module"
        homepage = "https://your-homepage.com"
        version = "1.0"
        ios.deploymentTarget = "16.0"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic = true
            export("com.zoho.apptics.kmp:crash:0.1-beta")
        }
    }
    sourceSets {
        iosMain.dependencies {
            api("com.zoho.apptics.kmp:crash:0.1-beta")
        }
    }
}

Option B - Direct framework export

 

Copiedkotlin {
    iosArm64() // Configure all required iOS targets
    iosSimulatorArm64()
    iosX64()

    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries.framework {
            baseName = "shared"
            isStatic = true
            export("com.zoho.apptics.kmp:crash:0.1-beta")
        }
    }

    sourceSets {
        iosMain.dependencies {
            api("com.zoho.apptics.kmp:crash:0.1-beta")
        }
    }
}

3. iOS app configuration

Update your 'AppDelegate.swift' to initialize crash tracking.

Copiedswift
import UIKit
import Apptics
import shared
import AppticsMXCrashKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

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

        // Initialize Apptics SDK first
        Apptics.initialize(withVerbose: true)

        // Register KMP crash reporter
        AppticsKMPCrashReporterKt.registerCrashReporter(KMPCrashReporter())

        return true
    }
}