Dependencies¶
The generated code needs a few libraries. By default the plugin adds them for you.
| Source set | Dependency | Version |
|---|---|---|
commonMain |
ch.ubique.uniffi:runtime |
same as the plugin |
commonMain |
com.squareup.okio:okio |
3.18.1 |
commonMain |
org.jetbrains.kotlinx:atomicfu |
0.33.0 |
commonMain |
org.jetbrains.kotlinx:kotlinx-coroutines-core |
1.11.0 |
jvmMain |
net.java.dev.jna:jna |
5.19.1 |
androidMain |
net.java.dev.jna:jna@aar |
5.19.1 |
androidHostTest |
net.java.dev.jna:jna |
5.19.1 |
The runtime¶
ch.ubique.uniffi:runtime contains the code that is the same for every crate: buffer handling,
type converters, the async helpers, and so on. It is published to Maven Central with the same
version as the plugin. Sharing one runtime is what lets multiple modules
exchange objects.
To manage the runtime yourself, for example to use a different version:
uniffi {
addRuntime = false
}
kotlin.sourceSets.commonMain.dependencies {
implementation("ch.ubique.uniffi:runtime:1.3.0")
}
The runtime must match the generator version. Bindings generated by one version and a runtime of another are not guaranteed to fit together.
The other libraries¶
To pick your own versions of okio, atomicfu, coroutines or JNA:
uniffi {
addDependencies = false
}
You then have to add all of them yourself, including JNA for JVM and the @aar variant for
Android.
ProGuard / R8¶
The runtime ships consumer rules for R8. They keep JNA itself, and every member of classes that
extend or implement JNA types, which covers the generated library interface, structures and
callbacks. A minified Android app doesn't need extra rules. If you disable addRuntime, copy the
rules from
runtime/consumer-rules.pro.