【发布时间】:2021-04-30 09:20:51
【问题描述】:
我尝试在 Kotlin Multiplatform XCFramework 中使用 Swift 代码。
我有一个扩展了该协议的默认实现的协议
@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 协议默认实现?
【问题讨论】:
标签: swift kotlin kotlin-multiplatform xcframework