max*_*max 7 kotlin kotlin-native kotlin-multiplatform
我想为 android 和 IOS 创建一个简单的多平台应用程序,这是我的常用模块配置
kotlin{
sourceSets{
commonMain{
dependencies{
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61"
}
}
}
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith('iphoneos') ? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios'){
binaries {
framework('shared')
}
}
fromPreset(presets.android, 'android')
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在通用模块中的预期界面
package common
expect interface Response{
fun submitResponse(res:Int)
}
Run Code Online (Sandbox Code Playgroud)
问题是 IDE 向我显示了响应接口的错误,expected has no actual declaration for common JVM
但我没有将 JVM 声明为预设。
这些是 android 和 IOS 的实际接口
package common
actual interface Response{
actual fun submitResponse(res:Int)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
854 次 |
| 最近记录: |