https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Andrey Makovskiy

06/06/2019, 8:36 AM
Is it possible build Apple Framework in multiplatform project with generics support? Currently all generics converted to type Any? Nothing helps.
r

ribesg

06/06/2019, 8:37 AM
Kotlin -> Native generics are not supported
This is an incomplete implementation iirc, and I guess it should be part of 1.3.40
a

Andrey Makovskiy

06/06/2019, 8:52 AM
I found this post: https://medium.com/@kpgalligan/kotlin-native-interop-generics-15eda6f6050f and also this article https://github.com/JetBrains/kotlin-native/blob/master/OBJC_INTEROP.md both recommend to add this to build.gradle compilations.main { outputKinds("framework") extraOpts "-Xobjc-generics" }
r

ribesg

06/06/2019, 10:06 AM
Yes but you need to use Kotlin 1.3.40
I don’t think it’s in 1.3.31
k

kpgalligan

06/06/2019, 2:02 PM
That post was an overview of the plan before implementing. It’s mostly correct, but I need to do another post I think
Not sure how to comment on the completeness. I think it’s as complete as we can make it with Objc. No generic methods for example. You do need to wait until 1.3.40
r

ribesg

06/06/2019, 2:06 PM
Yes that’s what I meant by incomplete, it doesn’t match JVM Kotlin Generics capabilities and never will (if I understood correctly)
But it’s far better than what we currently have, nothing
k

kpgalligan

06/06/2019, 2:09 PM
Yeah, Kotlin, Swift, and Objc are all different. Even with direct Swift interop there would be some features added and removed. Swift has generic functions, but no variance. Objc does have variance, and even though Swift doesn’t recognize it, if you’re talking to an Objc class from Swift, it’s looser with casting around variance issues. Yada yada, yes, unless Swift adds the generic features found in Kotlin, support will be constrained