Prerequisites
Kotlin side (library author)
JDK 17+
Gradle, via the included wrapper (
./gradlew).NET SDK 10.0+, only if you bind a NuGet package into Kotlin (
nuget { dependencies { dependency(...) { bind { ... } } } }). Publishing needs no .NET SDK:packNugetwrites the.nupkgitself.If Gradle can't see
dotneton itsPATH(an IDE-launched daemon, say), setnuget.dotnetto the executable's absolute path in the root project'slocal.properties:nuget.dotnet=/usr/local/share/dotnet/dotnetA Gradle property of the same name (
-Pnuget.dotnet=...orgradle.properties) also works;local.propertieswins. A path that is relative, missing or not executable fails the build rather than falling back toPATH.
C# side (consumer)
.NET SDK 10.0+
Bindings are pre-generated at Kotlin compile time via KSP, so the consumer needs no additional tooling.
Compatibility
kotlin-native-nuget | Kotlin | KSP (bundled) | Gradle | JDK | .NET |
|---|---|---|---|---|---|
|
|
|
| 17+ |
|
|
|
|
| 17+ |
|
|
|
|
| 17+ |
|
Releases up to 0.8.0 shipped one Kotlin Gradle plugin and silently upgraded yours to it. From 0.9.0 the plugin uses the Kotlin version you declare, from a floor up to the last tested release.
Below
2.4.0the build fails at configuration time. The publishednuget-runtimeandnuget-annotationslibraries are built at klib ABI 2.4, which an older Kotlin/Native compiler can't read.[nuget] Kotlin 2.3.21 is not supported. kotlin-native-nuget 0.9.0 needs Kotlin 2.4.0 or newer: its nuget-runtime and nuget-annotations klibs are built at klib ABI 2.4, which an older Kotlin/Native compiler cannot read. Update the Kotlin Gradle plugin to 2.4.0 or newer.Above
2.4.20the build warns and continues:Kotlin 2.5.0 is newer than the last version kotlin-native-nuget 0.9.0 was tested with (2.4.20). It is expected to work. If it does not, update the plugin.Patch releases above2.4.20warn too. Only the leadingmajor.minor.patchis compared, so2.4.0-RC2counts as2.4.0.KSP is applied by the plugin, so you don't choose a KSP version and it doesn't have to match your Kotlin version.
Supported native targets
The plugin maps Kotlin/Native targets to NuGet runtime identifiers (RIDs), used for the runtimes/{rid}/native/ package layout:
Kotlin target | RID | Exercised in CI |
|---|---|---|
|
| Yes |
|
| Yes |
|
| No |
|
| Yes |
|
| Compiled only |
The runtime library that generated bindings depend on is published for every target in this table, including linuxArm64.
A target outside this table is skipped with a warning, and if no configured target is supported, the plugin skips the whole project for that build. See Getting started for target configuration.