In my Kotlin (multiplatform) code, I have several ...
# kotlin-native
s
In my Kotlin (multiplatform) code, I have several `object`s. Let's say for instance I have one named "SomeHelper" that contains "static" methods. Why, in my "MyProject.framework/Headers/MyProject.h" file, does it add a Kt suffix to my
swift_name
? And why do I see
objc_subclassing_restricted
?
Copy code
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("SomeHelperKt")))
@interface ProjectNameSomeHelperKt : KotlinBase
a
Hello! Can you share it’s Kotlin declaration? Usually,
*Kt
suffix is used for top-level functions and variables, so it should not appear on objects. Subclassing is described here (https://github.com/JetBrains/kotlin-native/blob/master/OBJC_INTEROP.md#subclassing-kotlin-classes-and-interfaces-from-swiftobjective-c).
s
Here's a sample of what my Kotlin declaration would look for one of those `object`s:
Copy code
object SomeHelper {
    fun someFunction1(): Array<String> {
        return arrayOf("some string 1", "some string 2")
    }

    @ExperimentalUnsignedTypes
    @ExperimentalStdlibApi
    fun someFunction2(array: UByteArray): SomeDataClass {
        ...
        ...
        return SomeDataClass("string 3", "string 4", 200u, 200u)
    }
}
@Artyom Degtyarev [JB] Ok, now I added a dummy simple helper
object
with only 1 function and it generated the correct/expected name. I wonder if the fact that I use attributes such @ExperimentalUnsignedTypes and @ExperimentalStdlibApi in my `object`s alter the names generated, and if so, if there's a way to counter this. I'll keep experimenting, but if someone has a solution, let me know.
@Artyom Degtyarev [JB] Could it be because unsigned numeric types are implemented as inline classes?
All right, looks like I was responsible for the problem. I had renamed my packages, but duplicates (classes, objects, enums, etc.) from the old packages were somehow still in my project. Once I deleted them and build again on iOS, I got rid of the 'Kt' suffix in the generated header file.
👍 1