hello 👋🏻 , I am running into an issue with multiplatform. I am exposing
Duration
and the iOS project isn't able to see any of the kotlin datetime functions/classes.
What's the recommended approach for working with this on the iOS side?
Oh, my mistake then. This is still helpful, thanks 👍🏻
m
mkrussel
01/01/2023, 12:55 AM
Duration
is an inline value class and the Objective-C interop doesn't suppor them, and they all become just
Longs
. I found this hard to use from Swift since the
Long
doesn't represent something simple like total milliseconds, but instead encodes information about the duration in the most significant bit. I ended up creating a wrapper around duration for my public API.
r
Ryan Simon
01/01/2023, 4:16 PM
Thanks for that insight @mkrussel. Do you mind sharing more about your duration wrapper?
m
mkrussel
01/03/2023, 1:24 PM
Not much to say about it. It's just a normal class that exposes a lot of the same functionality as
Duration
and delegates to a
Duration
.
For me, we created our class before we looked at Kotlin's
Duration
class. When we tried to switch to it, we found that using
Duration
from Swift was hard, so instead kept the original class design and changed the implementation.