[Resolved] I’ve started seeing this error on iOS recently `* thread #1, queue = 'com.apple.main-thre...
l
[Resolved] I’ve started seeing this error on iOS recently
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
`frame #0: 0x000000010d014d10 MyFramework`kfun:kotlinx.serialization.json.Json#encodeToString(kotlinx.serialization.SerializationStrategy<00&gt;;00){0§<kotlin.Any?>}kotlin.String [inlined] Composer at Composers.kt139` I’m using a standard
Copy code
json.encodeToString(Model.serializer(), model)
using
Copy code
private val json = Json {
    isLenient = true
    ignoreUnknownKeys = true
}
Everything works fine on Android, but fails on iOS. What should I be looking for?
I looked at the code and saw that I was creating a lambda in Swift that receives a Kotlin object and is passed into a Kotlin function. In this lambda, I take this Kotlin Serializable object and call a Kotlin function that uses encodeToString under the hood. By moving the serialization step to inside Kotlin code and passing the resulting String to the lambda, this appears to be resolved. I think it was just crossing language boundaries too many times.
101 Views