3

我正在制作一个KMM application,我已经完成了 Android 部分,没有任何问题,一切正常。

然而,当我通过打开iosMyApp.xcworkspace文件启动 iOS 版本并启动编译时,会出现此错误。

The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidAndroidTestRelease
 * androidTestFixtures
 * androidTestFixturesDebug
 * androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
w: skipping /Users/jeremieguillot/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.6.3/1912839739c3051183691e878ef7e4d17366f4f4/ktor-client-serialization.klib. **Incompatible abi version. The current default is '1.4.2', found '1.5.0'. The library produced by 1.5.20 compiler**
e: Could not find "/Users/jeremieguillot/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.6.3/1912839739c3051183691e878ef7e4d17366f4f4/ktor-client-serialization.klib" in [/Users/jeremieguillot/AndroidStudioProjects/SpotABivouac/iosSpotApp/Pods, /Users/jeremieguillot/.konan/klib, /Users/jeremieguillot/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/common, /Users/jeremieguillot/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/platform/ios_x64]
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
----- End of the daemon log -----


FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
> **Task :shared:compileKotlinIos**
**Command PhaseScriptExecution failed with a nonzero exit code**

目前,我在 iOS 部分没有任何内容。

这是我的项目的配置。 build.gradle.kts (:shared)

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    kotlin("plugin.serialization") version "1.5.10"
}

version = "1.0"

kotlin {
    android()

    val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64

    iosTarget("ios") {}

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "15.0"
        frameworkName = "shared"
        podfile = project.file("../iosSpotApp/Podfile")
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1")
                implementation("io.ktor:ktor-client-core:1.6.3")
                implementation("io.ktor:ktor-client-serialization:1.6.3")
                implementation("com.russhwolf:multiplatform-settings-no-arg:0.7.7")
            }
        }

        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-android:1.6.3")
            }
        }

        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13.2")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-ios:1.6.3")
            }
        }
        val iosTest by getting
    }
}

android {
    compileSdk = 31
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 23
        targetSdk = 31
    }
}

构建.gradle.kts

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.0-alpha12")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
        classpath("com.apollographql.apollo:apollo-gradle-plugin:2.5.9")
        classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}

我尝试将此行修改为旧版本,但没有成功。

implementation("io.ktor:ktor-client-ios:1.6.3")

有没有人有解决方案或有什么需要调查的?

4

1 回答 1

2

我能够通过将 Kotlin 从 1.5.10 更新到 1.5.20 来解决这个问题。

于 2021-10-11T08:15:12.677 回答