https://kotlinlang.org logo
Title
b

Bradleycorn

04/19/2023, 7:54 PM
Per the Swift/ObjC interop docs:
The names of Kotlin classes and interfaces are prefixed when imported to Objective-C. The prefix is derived from the framework name.
Is there a way to customize/override the prefix?
x

xxfast

04/19/2023, 8:03 PM
does the framework baseName not work? (as seen here)
binaries {
  framework {
    baseName = "Demo"
  }
}
b

Bradleycorn

04/19/2023, 8:03 PM
doesn’t seem too
I have a module named “adw-program” In it’s build.gradle.kts, I have:
listOf(
     iosX64(),
     iosArm64(),
     iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "TheProgram"
        }
    }
but in my swift code, classes still use a prefix of
Adw_program
l

leandro

04/20/2023, 10:05 AM
the frameworkName is different than baseName. You should be able to set the name you want through
framework(name) {}
k

Kevin S

04/20/2023, 7:59 PM
Not quite the same but you can customize class names using @objcname https://kotlinlang.org/docs/native-objc-interop.html#name-translation