https://kotlinlang.org logo
s

Stylianos Gakis

02/25/2022, 10:19 AM
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?
j

Jon Bailey

02/25/2022, 11:12 AM
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

02/25/2022, 11:19 AM
this is my understanding as well
s

Stylianos Gakis

02/25/2022, 11:39 AM
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

02/25/2022, 12:27 PM
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.
j

Jon Bailey

02/25/2022, 1:09 PM
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 :/
😢 1
4 Views