【问题标题】:Kotlin/Native compileKotlinIosX64 task fails when building iOS appKotlin/Native compileKotlinIosX64 任务在构建 iOS 应用程序时失败
【发布时间】:2020-07-31 17:30:52
【问题描述】:

我有一个 Kotlin 多平台项目。我最近更新到 Kotlin 1.4-M2(我需要它来解决 Ktor 的一些问题)。 在更新所有必需的库、解决所有 gradle 问题并成功编译我的 Android 项目后,我现在在构建 iOS 应用程序时遇到以下错误:

Task :shared:compileKotlinIosX64
e: Compilation failed: Could not find declaration for unbound symbol org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl@56f11f08
* Source files: [all shared folder kt files]
 * Compiler version info: Konan: 1.4-M2 / Kotlin: 1.4.0
 * Output kind: LIBRARY
e: java.lang.IllegalStateException: Could not find declaration for unbound symbol org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl@56f11f08
    at org.jetbrains.kotlin.ir.util.ExternalDependenciesGeneratorKt.getDeclaration(ExternalDependenciesGenerator.kt:76)

奇怪的是,在源文件中它显示了共享代码文件夹中的所有文件。我检查了一下,绝对所有的 kt 文件都出现在那里。所以我的猜测是在构建共享代码时这是一些问题,但似乎不是任何库的特定问题。

这是我的 build.gradle.kts 外观的略微简化版本:

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("kotlinx-serialization")
    id("com.android.library")
    id("io.fabric")
}

// CocoaPods requires the podspec to have a version.
version = "1.0"

tasks {
    withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}

kotlin {
    ios()
    android()

cocoapods {
    // Configure fields required by CocoaPods.
    summary = "Some description for a Kotlin/Native module"
    homepage = "Link to a Kotlin/Native module homepage"
}

sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
                api("org.kodein.di:kodein-di:7.1.0-kotlin-1.4-M3-84")
                implementation("io.mockk:mockk:1.9.2")

                api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")

                api("com.russhwolf:multiplatform-settings:$multiplatformSettingsVersion")

                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-json:$ktorVersion")
                implementation("io.ktor:ktor-client-logging:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")
            }
        }
}
}

库版本如下:

val ktorVersion = "1.3.2-1.4-M2"
val kotlinVersion = "1.4-M2"
val coroutinesVersion = "1.3.7-native-mt-1.4-M2"
val serializationVersion = "0.20.0-1.4-M2"
val multiplatformSettingsVersion = "0.6-1.4-M2"

值得一提的是,在 iOS 中使用 1.3.72 时可以正确构建。

【问题讨论】:

  • 第一个问题,Mockk 是如何工作的?没有原生实现。
  • @KevinGalligan 好问题!它没有。我首先为 Android 制作了这个应用程序并在那里使用它,但不知道那个小细节。现在我不能再使用它了,很遗憾。我会尽快删除它...
  • 另外,除非库不可用,否则我会改用 RC 版本而不是 M2
  • @KevinGalligan 是的,由于协程,我一直坚持这一点,但实际上我刚刚检查过,他们昨天刚刚发布了它。会试一试
  • @KevinGalligan 感谢您的建议,它成功了。

标签: kotlin multiplatform kotlin-multiplatform kotlin-native


【解决方案1】:

正如@KevinGalligan 建议的那样,我将 Kotlin 和所有相关库更新为 1.4.0-rc,问题就解决了。

1.4-M2 的根本问题仍然未知。

【讨论】:

    猜你喜欢
    • 2023-01-11
    • 1970-01-01
    • 2019-10-28
    • 2020-03-16
    • 1970-01-01
    • 2019-06-06
    • 2019-08-16
    • 2022-11-11
    • 1970-01-01
    相关资源
    最近更新 更多