Coroutine called from iOS - subclasses aren't propagated from Kotlin to Objective-C/Swift


#1

In Idea, I created this class, as a kotlin multiplatform:

package sample

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class Sample {
    suspend fun sayHello() {
        println("hello")
    }

    fun wrapper() {
        GlobalScope.launch {
            sayHello()
        }
    }
}

I am then calling this from iOS/Xcode, with this:

import UIKit
import HelloCoroutines

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()            
        sendSayHello()
    }

    func sendSayHello() {
        DispatchQueue.main.async {
            let sample = Sample()
            sample.wrapper()
        }
    }
}

And when I run it, I get this error message:

Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren’t propagated from Kotlin to Objective-C/Swift.

Is this not allowed yet on Kotlin native?

Thanks,
Eduardo