(Kotlin/Native) Suspendable functions inside iOS framework


I’ve run into quite an issue lately. We are using suspend func inside common project but it’s not being generated in iOS framework.

Any way how to fix this or any workaround?

What I mean is for example this piece of code

interface CommandHandler<in T : Command> {

    suspend fun handle(command: T)

will only generate this inside of objc framework

@protocol PrefixCommandHandler

I would be really grateful for any help. Thank you.

workaround is use class Continuation for callbacks. see kotlin_multiplatform/ReposRepository.kt at master · shakurocom/kotlin_multiplatform · GitHub (kotlin common-ios part) & kotlin_multiplatform/ReposRepository.swift at master · shakurocom/kotlin_multiplatform · GitHub (ios app part)
also useful link - Building Multiplatform Project on Kotlin/Native | by Moses Kim | AndroidPub | Medium

1 Like