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...
@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
Casey Brooks
01/29/2021, 12:56 AM
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
Sam
01/29/2021, 6:35 AM
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
Nicholas Tian
02/01/2021, 10:26 PM
@Sam Thanks Sam! Good to know this isn't possible yet.