Hi everyone, I have a question regarding Kotlin vs...
# multiplatform
m
Hi everyone, I have a question regarding Kotlin vs Objc/Swift static properties. Kotlin doesn’t have any explicit support of static functions. Instead, we use companion objects. Following example is often used in factory classes.
Copy code
class MyClass {
  ...
  companion object {
    fun companionFun()
  }
}
When we generate ObjC code out of this example it creates one interface for
MyClass
and another one for
MyClass.Companion
. Then, in Swift we use it as
MyClass.companion.companionFun()
. The issue is
companion
nor
companionFun
aren’t static because
companion
is a singleton object. Is there a way how to generate Swift static functions for Kotlin functions without the need of second interface? I found one feature ticket which would potentially solve this issue but it is without any activity for a long time. https://youtrack.jetbrains.com/issue/KT-44862
2