Export Dependencies To Kotlin
How It works
On completion with using external dependencies, it's possible to export them to your Kotlin module, if they are compatible.
Note
If your package doesn't work with the plugin, please create an issue.
Bridge Incompatible Dependencies
In a case the exported dependency is written in Swift, manual work needs to be done like this.
For example, the CryptoSwift can't work directly on Kotlin, so the Plugin's bridge is here to fill the gape between Kotlin and Swift.
Example
Gradle
The following configuration exports to Kotlin the package FirebaseAnalytics which is a ObjC library.
Don't export incompatible library
Exporting an incompatible library is useless and will only increase build time.
build.gradle.kts
swiftPackageConfig {
create("[cinteropName]") {
dependency {
remotePackageVersion(
url = uri("https://github.com/firebase/firebase-ios-sdk"),
products = {
add("FirebaseAnalytics", exportToKotlin = true), // exported
add("FirebaseCore") // non-exported
},
version = "11.8.0",
)
// Another SwiftDependency
// ...
)
}
}
Bridge
iosMain/kotlin/com/example/myKotlinFile.kt
import FirebaseAnalytics.FIRConsentStatusGranted
@ExperimentalForeignApi
val consentStatusGranted = FIRConsentStatusGranted
Note
The bridge can remain empty as we don't need it; we only want to use the exported product.