https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
e

eygraber

07/13/2022, 7:28 PM
Why do enums turn into
KotlinEnum
in swift? Why not a native enum?
m

mbonnin

07/13/2022, 7:33 PM
I guess the Kotlin one has
.name
and
.values()
, etc... that the swift one doesn't have
There's no 1:1 mapping
m

mkrussel

07/13/2022, 7:35 PM
Kotlin Native only creates Objective-C bindings and not Swift.
m

mbonnin

07/13/2022, 7:35 PM
Right
I said "swift", I meant "obj-c" 🙂
I'm not sure what "obj-c" enums are but there is very little chance it has all the same behaviour as the Kotlin ones
m

mkrussel

07/13/2022, 7:37 PM
I think they are much closer to C enums where there are grouped constants. No functions.
m

mbonnin

07/13/2022, 7:38 PM
Yea exactly. Kotlin is a much richer language, there's a lot more than just a group of constants
If only because they have
.hashCode()
and
.equals()
e

eygraber

07/13/2022, 7:39 PM
If Swift bindings ever get supported, would it use swift enums?
m

mkrussel

07/13/2022, 7:40 PM
Maybe
m

mbonnin

07/13/2022, 7:40 PM
IIRC @kpgalligan said Swift bindings are most probably never going to happen at his talk in DroidCon last week 🙃
😭 2
🥲 4
m

mkrussel

07/13/2022, 7:41 PM
Supporting Swift keeps getting pushed out on the road map, so I would not expect anything for a long time.
j

John O'Reilly

07/13/2022, 7:42 PM
something to look out for in not too distant future is some work being done at TouchLab that will auto generate Swift adapter code. @kpgalligan also talked about that at little at Droidcon Berlin last week (https://speakerdeck.com/kpgalligan/sdk-design-and-publishing-for-kotlin-multiplatform-mobile?slide=102) ...don't know full details but seems promising
☝️ 2
🙏 2
k

kpgalligan

07/13/2022, 7:46 PM
Not never. Just delayed for a while. However, swift bindings won't "solve" all problems. Like sealed classes won't automatically become enums. That kind of thing. See the slides and hopefully the video soon.
👍 3
We're working on a thing to essentially compile and link swift into the kotlin framework. That should help generate a swift-assisted interface. There are other projects that do this, of course.
🤩 3
❤️ 5
s

samuele794

07/14/2022, 7:13 AM
@kpgalligan is there a roadmap available?
h

hfhbd

07/14/2022, 9:10 AM
Swift and Kotlin Native both uses LLVM. I don't know anything about LLVM, but I hoped the LLVM IR is compatible, isn't it?
k

kpgalligan

07/14/2022, 12:37 PM
They're not automatically compatible, but direct interop is certainly possible. It'll happen at some point.
@samuele794 no hard roadmap. Proof of concept demoed at droidcon Berlin. If we can avoid unforseen issues, I think we'll be targeting droidcon NYC for at least private preview. We do need some feed back on what people want generated. Working on some features now, but the design isn't quite as straightforward s I'd assumed (but what ever is?)
💙 2
s

samuele794

07/14/2022, 1:10 PM
@kpgalligan I cheer for you and this concept
cheers 2
p

Paul Woitaschek

07/14/2022, 7:20 PM
We use our swift generator that maps sealed classes and enums to enums for about half a year now and faced almost no issues so far. It's definitely doable. But ofc it's not in the shape of a library that has to fit all use cases - only ours.
👍 2
4 Views