xcode 归档KMM应用,KotlinClass不在范围内

xj3cbfub  于 2023-04-07  发布在  Kotlin
关注(0)|答案(2)|浏览(139)

所以我在https://github.com/WhiteWhiskyWolf/all_you上有一个KMM应用程序
我似乎无法归档应用程序。当我通过Xcode build为设备构建时,它可以工作。但是,如果我尝试归档应用程序,无论是通过Fastlane的XCode,每个Kotlin类都会返回X not in scope
在查看构建日志时,Gradle构建任务是成功的,所以我有点不明白它为什么要这样做。
所以我加了

framework {
            // Required properties
            // Framework name configuration. Use this property instead of deprecated 'frameworkName'
            baseName = "shared"

            // Optional properties
            // Specify the framework linking type. It's dynamic by default.
            isStatic = false
            // Dependency export
            export(project(":shared"))
            transitiveExport = false // This is default.
            // Bitcode embedding
            embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.BITCODE)
        }

        // Maps custom Xcode configuration to NativeBuildType
        xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
        xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE

并针对我的iosApp目标而不是共享目标进行编译,现在我得到了

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:linkPodReleaseFrameworkIosArm64'.
> java.lang.StackOverflowError (no error message)

编辑:
添加依赖项

sourceSets {
        val commonMain by getting {
            dependencies {
                api("io.insert-koin:koin-core:${Koin.version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${KotlinVersions.coroutines}")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${KotlinVersions.serialization}")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:${KotlinVersions.date}")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation("io.mockative:mockative:${Mockk.version}")
                api("io.insert-koin:koin-test:${Koin.version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KotlinVersions.coroutines}")
                implementation("app.cash.turbine:turbine:${Turbine.version}")
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.gms:google-services:${Android.googleService}")
                implementation("com.google.android.gms:play-services-auth:${Firebase.playServiesVersion}")
                implementation("io.insert-koin:koin-android:${Koin.version}")
                implementation(project.dependencies.platform("com.google.firebase:firebase-bom:${Firebase.firebaseBom}"))
                implementation("com.google.firebase:firebase-auth-ktx")
                implementation("com.google.firebase:firebase-firestore-ktx")
                implementation("com.google.firebase:firebase-storage-ktx")
                implementation("com.google.firebase:firebase-messaging-ktx")
            }
        }
        val androidUnitTest by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
cnwbcb6i

cnwbcb6i1#

看起来你正面临着归档你的应用程序的问题,尝试一步一步地解决这个问题:
你需要在ide中安装最新的kmm插件
检查build.gradle文件:

plugins {
    kotlin("multiplatform") version "newest"
}

用最新可用版本替换最新版本。
remove:isStatic = false和embedBitcode(..)
框架块中的行,因为存档不需要这些行:

framework {
        baseName = "shared"

export(project(":shared"))
transitiveExport = false

}
xcodeConfigurationToNativeBuildType块看起来很好,因此不需要进行更改。
使用最新的xcode
在尝试存档之前清理并重新生成项目
另外,请尝试删除项目目录中的.gradle文件夹,然后重建项目。
确保共享模块没有任何递归依赖项,这可能导致过度错误

wkyowqbh

wkyowqbh2#

所以答案是这个项目最初是为“常规框架”设置的,但我在gradle中使用了“cocoapods”。所以答案实际上是删除编译Kotlin的构建阶段,它开始工作。特别是
./gradlew :shared:embedAndSignAppleFrameworkForXcode

相关问题