I use ktor client + kotlin-native + kotlinx-serial...
# ktor
a
I use ktor client + kotlin-native + kotlinx-serialization and i'm getting following error on ios side:
Copy code
io.ktor.client.call.ReceivePipelineException: Fail to run receive pipeline
Copy code
ext.kotlin_version = '1.3.10'
    ext.coroutines_version = '1.0.1'
    ext.ktor_version = '1.0.1'
    ext.serialization_version = '0.9.1'
e
Hi @ahulyk, could you check the exception cause?
a
@e5l it happens always if i try to serialize json:
Copy code
private fun createClient(): HttpClient {
    return HttpClient {
        install(JsonFeature) {
            serializer = KotlinxSerializer()
        }
    }
}

fun makeRestCall(callback: (Hello) -> Unit) {
    val address = "<https://my-json-server.typicode.com/typicode/demo/profile>"
    GlobalScope.apply {
        launch(applicationDispatcher) {
            val result: Hello = createClient().get(address)
            callback(result)
        }
    }
}

@Serializable
data class Hello(
    val name: String
)
On jvm/android it works just fine. Btw, i use kotlin 1.3.10 not 1.3.11 because on that version i got kotlin.native.concurrent.InvalidMutabilityException
e
@sandwwraith
a
@e5l issue has been resolved by registering serializer manually:
Copy code
serializer = KotlinxSerializer().apply {
                register(Hello.`$serializer`)
            }
👍 2
s
you can use
.serializer()
function
y
@sandwwraith Is this a hot fix? If I had 1000 data classes, do I have to register all of them?
s
Since there are no reflection in Native, yes, you need to register them manually. Probably some auto-generated modules for bulk registering would be available in the future
y
Thank you 🙏