在项目“:shared”中找不到 kotlin 移动平台任务 'Debug'

kotlin mobile platforms Task 'Debug' not found in project ':shared'

我正在尝试将 kmm 共享模块添加到我的 ios/android 应用程序 但是,我从 Xcode 运行

那里收到了这条消息

显示最近的消息 配置项目“:shared”时出现问题。

> Could not identify build type for Kotlin framework 'shared' built via cocoapods plugin with CONFIGURATION=Staging.

  Add xcodeConfigurationToNativeBuildType["Staging"]=NativeBuildType.DEBUG or xcodeConfigurationToNativeBuildType["Staging"]=NativeBuildType.RELEASE to cocoapods plugin configuration

然后我将这一行添加到我的共享 Gradle 配置中 显示最近消息 配置项目“:shared”时出现问题。

xcodeConfigurationToNativeBuildType["Staging"]=
         org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG

出了什么问题: 在项目“:shared”中找不到任务 'Debug'。

无论如何我有这个警告waringsws⚠️

Unable to detect Kotlin framework build type for CONFIGURATION=Staging Debug automatically. Specify 'KOTLIN_FRAMEWORK_BUILD_TYPE' to 'debug' or 'release

这里是 gradle.kts

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
}

version = "1.0"

kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "12.1"
        podfile = project.file("../../bas-ios/Podfile")
        framework {
            baseName = "shared"
        }



         xcodeConfigurationToNativeBuildType["Staging"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG

    }
    
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting
        val androidTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
}

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

感谢@ArtyomDegtyarev, 当您 Xcode 配置包含 space 如“调试付费”

时出现此问题

这行不通

xcodeConfigurationToNativeBuildType["Debug paid"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG

太阳 : 更新到科特林 1.6 从 xcode 配置中删除 space ["Debug_paid"]