我正在尝试学习如何使用 Kotlin 进行 IOS/Android 多平台开发。
在进行动手教程时,可在此处获取:https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/03_CreatingSharedCode
我在文件 SharedCode/src/iosMain/kotlin/actual.kt 中收到错误 Unresolved reference: platform
:
package com.jetbrains.handson.mpp.mobile
import platform.UIKit.UIDevice
actual fun platformName(): String{
return UIDevice.currentDevice.systemName() +
" " +
UIDevice.currentDevice.systemVersion
}
它只适用于 MacOS 还是我遗漏了什么?
感谢您的帮助。
最佳答案
看起来您的 Android Studio 和项目中的 Kotlin 运行时/编译器版本不匹配。确保将它们与最新且相同的版本对齐。例如,如果您的 IDE 中的 Kotlin 插件是 1.3.72,那么请确保您的项目 Gradle 中的 kotlin-gradle-plugin 也使用的是 1.3.72 版本。
关于android - Kotlin IOS/Android 跨平台实践教程 : Unresolved reference: platform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59337063/