【发布时间】:2026-01-02 08:00:01
【问题描述】:
这个问题是这个线程的延续: https://github.com/Kotlin/kotlinx.coroutines/issues/246#issuecomment-407023156
我正在尝试在针对 iOS 的 Kotlin/Native 项目中使用 org.jetbrains.kotlinx:kotlinx-coroutines-core-native:0.23.4-native-1。
build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"
}
}
apply plugin: 'kotlin-platform-native'
repositories {
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
sourceSets {
main {
component {
target 'ios_arm32', 'ios_arm64', 'ios_x64'
outputKinds = [KLIBRARY]
}
}
}
dependencies {
expectedBy project(':common')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:0.23.4-native-1"
}
kotlinx:kotlinx-coroutines-core-native 依赖项似乎不起作用,因为会产生如下构建错误:
error: unresolved reference: coroutines
import kotlinx.coroutines.experimental.*
^
如果我手动包含 org.jetbrains.kotlinx:kotlinx-coroutines-core-native_release_ios_x64:0.10.3-native 等工件依赖项,则会收到编译器异常:
exception: java.lang.IllegalStateException: Could not find "atomicfu-native"
即使我还添加了org.jetbrains.kotlinx:atomicfu-native:0.10.3-native 依赖项,此错误仍然存在。
【问题讨论】:
标签: kotlin kotlinx.coroutines kotlin-native