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

Tzahi Moyal

02/05/2019, 7:31 AM
Hi, I have Serializable class and I used kotlinx.serialization, did someone know how I can use it in iOS SWIFT? I’m trying to parse JSON with the class I’d created
s

svyatoslav.scherbina

02/05/2019, 7:39 AM
Hi,
Hi, I have Serializable class and I used kotlinx.serialization, did someone know how I can use it in iOS SWIFT?
What is “it”? Are you trying to parse JSON to Kotlin class from Swift?
t

Tzahi Moyal

02/05/2019, 7:42 AM
I build multi platform library in Kotlin and now I’m trying to use it on iOS
s

svyatoslav.scherbina

02/05/2019, 7:53 AM
You can define Kotlin function that serializes or deserializes particular Kotlin class, and then use this function from Swift.
t

Tzahi Moyal

02/05/2019, 7:59 AM
I did that and then I got this error: “Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren’t propagated from Kotlin to Objective-C/Swift. Other exceptions can be propagated as NSError if method has or inherits @Throws annotation. Uncaught Kotlin exception: kotlin.NotImplementedError: An operation is not implemented: Obtaining serializer from KClass is not available on native due to the lack of reflection. Use .serializer() directly on serializable class.”
s

svyatoslav.scherbina

02/05/2019, 8:01 AM
This error contains all the required information to fix it.
Use .serializer() directly on serializable class
t

Tzahi Moyal

02/05/2019, 8:37 AM
I’ll try again
can you send me an example please?