m

    Marc Knaup

    3 years ago
    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 🙂
    Dominaezzz

    Dominaezzz

    3 years ago
    The can!
    With attributes like
    @JvmName
    .
    m

    Marc Knaup

    3 years ago
    That would change the name for Java, not for Kotlin.
    And about JS? Or different native targets? 🙂
    Dominaezzz

    Dominaezzz

    3 years ago
    They have theirs but I don't remember what they're called.
    Artyom Degtyarev [JB]

    Artyom Degtyarev [JB]

    3 years ago
    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

    Marc Knaup

    3 years ago
    @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 😮
    Artyom Degtyarev [JB]

    Artyom Degtyarev [JB]

    3 years ago
    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

    Marc Knaup

    3 years ago
    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.
    russhwolf

    russhwolf

    3 years ago
    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

    Marc Knaup

    3 years ago
    True, thanks.
    CName
    is for
    C
    exports 🙂 iOS code is ObjC which is very different and Swift will be even more different.
    russhwolf

    russhwolf

    3 years ago
    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

    Marc Knaup

    3 years ago
    As I said, I have no
    CName
    in my project. Neither in common code, nor in platform code 😕
    s

    svyatoslav.scherbina

    3 years ago
    CName
    doesn’t affect produced Objective-C/Swift API.
    ObjCName/SwiftName
    is not available yet.
    russhwolf

    russhwolf

    3 years ago
    Is there a ticket to track when that will be available?