Hi there, I am wondering. Is there a way to build ...
# kotlin-native
n
Hi there, I am wondering. Is there a way to build an iOS framework with Kotlin and Swift mixed together? I am hoping to build a Kotlin core library/framework that I can share between my iOS and Android framework. But not sure how or even this is possible to work out. My preliminary research on the internet returned nothing much...
c
Yes, my team uses Kotlin MPP in this way. You need to build a Fat Framework and publish it as a cocoapods dependency, which you then import from the iOS app. Here’s the docs for it https://kotlinlang.org/docs/reference/mpp-build-native-binaries.html#build-universal-frameworks
n
@Casey Brooks Thanks for the fast response! I know that you can build frameworks like this in Kotlin and produce an iOS fat framework. What I am unsure is that whether you can build a framework that mix Kotlin and Swift together in that said framework. (instead of building a framework in kotlin and use the framework in Swift).
c
I’m not 100% sure there, but I’d think it would fall somewhere in the category of obj-c interop. Probably not mixing the two sources as easily as you would with Java, but you can probably compile the Swift to a library and import that into the Kotlin build (or the other way around)
s
You cannot mix them in the same framework. Not even Apple does this when you add a Swift file to an existing objc app. You’ll need to make two frameworks. You can have one depend on the other perfectly fine but no circular relationships. If your Kotlin framework depends on the Swift one, you’ll need to make the Swift classes accessible via @objc annotations.
n
@Sam Thanks Sam! Good to know this isn't possible yet.