Thread
#multiplatform
    Stylianos Gakis

    Stylianos Gakis

    7 months ago
    Is it not possible to get access to Swift's Result type inside iosMain? I'm still not 100% how this works where we have access to some of Swift's types inside there but maybe not all of them?
    Jon Bailey

    Jon Bailey

    7 months ago
    As I understand it only objective-c types are available in Kotlin, as the interop is with objective-c instead to swift directly. I’m new though so someone else here probably has more knowledge 🙂
    a

    ade

    7 months ago
    this is my understanding as well
    Stylianos Gakis

    Stylianos Gakis

    7 months ago
    Right that’d make sense! My use case was basically that I have Arrow’s
    Either
    type and I wanted to map it into Swift’s
    Result
    function to make it more ergonomic for the iOS devs to deal with something more familiar. But I guess we’ll have our public functions expose Either as they do for Kotlin and then do the mapping locally in Swift instead, which may be annoying but maybe possible. Might have to re-think this sometime though, thanks for the input!
    a

    ade

    7 months ago
    I am exploring something similar. Unfortunately it's not possible to infer generics when making an extension function on top of a kmp class to map it to result that way.
    Jon Bailey

    Jon Bailey

    7 months ago
    Yeah not having direct swift interop is a huge pain, probably the biggest thing holding back more widespread adoption of kotlin native. I’m an iOS dev myself (have only used Kotlin for the last few months comapred to objective-c and swift for years and years) and it’s been quite annoying getting used to some of the pain points, particularly around generics. I’ve found https://github.com/icerockdev/moko-kswift to be quite useful, for example we use sealed classes quite a lot, and mapping them to enums is so much nicer. I’ve adapted their existing mapper to fit our use case more closely, so it’s fairly easy to write your own things.
    If I knew more about compilers and languages etc, I’d have a go at helping with the swift interop that is paused on the roadmap, but sadly I dont 😕