问题描述
我尝试在带有 Swift 代码的 Kotlin Multiplatform XCFramework 中使用。
@objc protocol Greeting {
var something: String { get }
}
extension Greeting {
var something: String {
return "Hello from Swift"
}
}
在 Platform.kt 中我正在编写
class GreetingImpl: NSObject(),GreetingProtocol {
override fun something(): String {
return (this as GreetingProtocol).something()
}
}
actual class Platform actual constructor() {
val object = GreetingImpl()
val value = object.something() //Application builds but falls here
}
如何在 Kotlin Multiplatform 中使用 Swift 协议默认实现?