You access a top-level property via the wrapper class: TopLevelPropertyKt.topLevelProperty.
We describe the top-level val property in Kotlin in file TopLevelProperty.kt
:
//TopLevelProperty.kt
val topLevelProperty = "Some value"
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 TopLevelPropertyKt
(file name in Kotlin + suffix Kt), with which you can access the desired property:
let _ = TopLevelPropertyKt.topLevelProperty
The property is readonly
, it cannot be changed.