You can access a top-level function via the wrapper class: TopLevelFunctionKt.topLevelFunction().
Let's describe the top-level function in Kotlin in the file TopLevelFunction.kt
:
//TopLevelFunction.kt
fun topLevelFunction() {
println("Hello from top-level function")
}
In Kotlin, similar code can be called directly, without specifying the file name, just specify import
the desired property.
On the Swift side, we get a wrapper class TopLevelFunctionKt
(file name in Kotlin + suffix Kt), with which you can access the desired function:
TopLevelFunctionKt.topLevelFunction()