Export Dependencies to Kotlin
Building on using external dependencies, you can export compatible packages directly to your Kotlin module — no bridge wrapping needed.
Note
If a package doesn't work with the plugin, please open an issue.
How It Works
When a dependency has an Objective-C compatible interface, it can be exported directly via exportToKotlin = true. The plugin runs cinterop over the package's generated Objective-C header and makes its types available in your Kotlin code.
Only export ObjC-compatible packages
Exporting a pure Swift package produces only empty SWIFT_TYPEDEFS in Kotlin and wastes build time. If the package is pure Swift, wrap it in a bridge instead.
Example
Exporting FirebaseAnalytics — an ObjC-compatible library — directly to Kotlin.
Gradle
kotlin {
listOf(
iosArm64(),
iosSimulatorArm64()
// and more Apple targets...
).forEach { target ->
target.swiftPackageConfig(cinteropName = "[cinteropName]") {
dependency {
remotePackageVersion(
url = uri("https://github.com/firebase/firebase-ios-sdk"),
version = "11.8.0",
products = {
add("FirebaseAnalytics", exportToKotlin = true) // exported
add("FirebaseCore") // not exported
},
)
// more dependencies...
}
}
}
}
Legacy (< 1.1.0)
Kotlin Usage
import FirebaseAnalytics.FIRConsentStatusGranted
@ExperimentalForeignApi
val consentStatusGranted = FIRConsentStatusGranted
Note
The bridge file can remain empty — no Swift wrapping is needed when exporting an ObjC-compatible product directly.