Skip to content

Getting Started

Requirements

Tool Minimum version
macOS + Xcode 16+
Kotlin 2.2.20+
Gradle 8.12+

Tip

Using an earlier Xcode version is possible — see Custom Swift Versions & Toolchains. Always use the latest Kotlin version when possible.


Apply the Plugin

Gradle Plugin Portal Version

build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.multiplatform")
    id("io.github.frankois944.spmForKmp") version "[version]"
}

Gradle Properties

Add the following to your gradle.properties:

gradle.properties
kotlin.mpp.enableCInteropCommonization=true

Initial Configuration

Use cinteropName to share a single bridge across targets and maintain compatibility with the legacy configuration style.

build.gradle.kts
kotlin {
    listOf(
        iosArm64(),
        iosSimulatorArm64()
        // and more Apple targets...
    ).forEach { target ->
        target.swiftPackageConfig(cinteropName = "[cinteropName]") {
            // creates src/swift/[cinteropName]/
        }
    }
}

When configuring a single target, cinteropName is optional — the target name is used by default.

build.gradle.kts
kotlin {
    iosArm64 {
        swiftPackageConfig {
            // creates src/swift/iosArm64/
        }
    }
}
Legacy (< 1.1.0)
build.gradle.kts
kotlin {
    listOf(
        iosArm64(),
        iosSimulatorArm64()
        // and more Apple targets...
    ).forEach {
        it.compilations {
            val main by getting {
                cinterops.create("[cinteropName]")
            }
        }
    }
}
build.gradle.kts
swiftPackageConfig {
    create("[cinteropName]") { // must match cinterops.create name
    }
}

See the full swiftPackageConfig reference for all available options.