You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

KMM集成iOS Pod报错:配置属性集重复问题求助

解决KMM集成iOS Pod时的Gradle属性冲突问题

问题根源

你同时在kotlin块下手动为每个iOS目标配置了binaries.framework,又在cocoapods块里定义了framework配置。这会导致Gradle生成两套功能重复的变体(debugFramework和podDebugFramework),它们的属性集完全一致,违反了Gradle 7+的唯一属性集要求,从而引发依赖解析错误。

解决方案

删除手动遍历iOS目标配置framework的代码块,仅保留cocoapods插件的framework配置即可——cocoapods插件会自动为所有iOS目标生成对应的framework变体。

修改后的build.gradle.kts配置

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

kotlin {
    android() {
        publishLibraryVariants("release")
    }

    // 移除手动配置framework的代码块,由cocoapods插件自动管理iOS目标
    ios()

    cocoapods {
        version = "1.0"
        summary = "sharedkmm"
        homepage = "sharedkmm"
        ios.deploymentTarget = "10.0"
        podfile = project.file("../iosApp/Podfile")
        pod("SSZipArchive") {
            version = "2.2.3"
        }
        pod("Reachability")
        framework {
            baseName = "sharedkmm"
            isStatic = false
            embedBitcode("disable")
        }
    }
}

后续操作步骤

  • 在项目根目录执行./gradlew clean清理Gradle缓存
  • 进入iOS项目目录,执行pod deintegrate && pod install重新集成Pod
  • 重新同步Gradle并构建项目

内容的提问来源于stack exchange,提问作者Đạt Đỗ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 13:02:18