It would be cool if a multiplatform projects can s...
# multiplatform
m
It would be cool if a multiplatform projects can somehow reflect a platform's naming conventions. E.g. having a property named
websiteUrl
in Kotlin and
websiteURL
in ObjC/Swift 🙂
d
The can!
With attributes like
@JvmName
.
m
That would change the name for Java, not for Kotlin.
And about JS? Or different native targets? 🙂
d
They have theirs but I don't remember what they're called.
a
There definitely are CName and JsName, just dig deeper to the Reference(https://kotlinlang.org/api/latest/jvm/stdlib/index.html). Not sure it has the same for ObjC, because of the prefix thing. But I suppose you are talking about importing ObjC things and making them prettier by default, don’t you?
m
@CName
seems to be for a different purpose though:
Makes top level function available from C/C++ code with the given name.
Even though it's documented I cannot actually use it in my code. It doesn't exist 😮
a
Did you import something like a
kotlin.native.CName
? In example here https://github.com/JetBrains/kotlin-native/tree/master/backend.native/tests/produce_dynamic/simple it looks like this should help. And yes, I might be misleading with it’s purpose, but I’m not sure what kind of name-changing you want to achieve.
m
It's probably not available because I'm in am multiplatform project with iOS target and not in a purely native Kotlin project. Also, I need to declare the name in common code, not in platform code.
r
You can try declaring
@OptionalExpectation annotation class CName
in your common code and
actual typealias CName = kotlin.native.CName
in your native. I haven't tried
CName
on iOS though so I don't know if there's something different for ObjC.
m
True, thanks.
CName
is for
C
exports 🙂 iOS code is ObjC which is very different and Swift will be even more different.
r
Yeah. I have no idea if it works or not but since https://youtrack.jetbrains.com/issue/KT-28801 is closed and the only thing that exists is
@CName
and not a separate
@ObjCName
, I figure maybe it's worth a try. Definitely nothing Swift-specific exists right now though because Kotlin only interops with Obj-C
m
As I said, I have no
CName
in my project. Neither in common code, nor in platform code 😕
s
CName
doesn’t affect produced Objective-C/Swift API.
ObjCName/SwiftName
is not available yet.
👌 1
r
Is there a ticket to track when that will be available?