ios - Kotlin 多平台 - 错误 ITMS-90171 : Invalid Bundle Structure

标签 ios xcode kotlin app-store kotlin-multiplatform

我在尝试在 Apple App Store 上使用 Kotlin Multiplatform 分发我的 iOS 应用程序时遇到问题:
ERROR

ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'Smiledu_app.app/Frameworks/shared.framework/shared' is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."


enter image description here
enter image description here
我检查了它在 Build Phases -> Copy Bundle Resources 中不存在
enter image description here
这是我的 build.gradle.kts
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    kotlin("plugin.serialization")
    id("com.android.library")
    id("kotlin-android-extensions")
    id("com.squareup.sqldelight")
}

repositories {
    gradlePluginPortal()
    google()
    jcenter()
    mavenCentral()
    maven {
        url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
    }
}

dependencies {
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
}

configurations {
    create("compileClasspath")
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
        versionCode = 1
        versionName = "1.0"
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
}

val libName = "shared"

kotlin {
    android()
    ios {
        binaries.framework(libName)
    }

    val coroutinesVersion = "1.4.1-native-mt"
    val serializationVersion = "1.0.0-RC"
    val ktorVersion = "1.4.0"
    val sqlDelightVersion = "1.4.3"
    val reactive_version = "1.1.18"

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common")

                // Coroutines
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2")

                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")

                //  KTOR
                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-json:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")

                // SQLDELIGHT
                implementation("com.squareup.sqldelight:runtime:$sqlDelightVersion")

                // Reactive
                implementation("com.badoo.reaktive:reaktive:$reactive_version")
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib")

                implementation("androidx.core:core-ktx:1.3.2")
                implementation("io.ktor:ktor-client-android:$ktorVersion")
                implementation("com.squareup.sqldelight:android-driver:$sqlDelightVersion")

                implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2")

                // HTTP
                implementation("io.ktor:ktor-client-ios:$ktorVersion")
                implementation("com.squareup.sqldelight:native-driver:$sqlDelightVersion")
            }
        }

        all {
            languageSettings.apply {
                progressiveMode = true
                useExperimentalAnnotation("kotlin.RequiresOptIn")
                useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
            }
        }
    }
}

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)

sqldelight {
    database("SmileduDataBase") {
        packageName = "com.example.smiledu"
        schemaOutputDirectory = file("src/commonMain/db/databases")
    }
}

最佳答案

从“嵌入框架”部分删除“shared.framework”可能会解决您的问题。确保在将构建推送到 TestFlight 之前在本地验证构建。

关于ios - Kotlin 多平台 - 错误 ITMS-90171 : Invalid Bundle Structure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66244025/

相关文章:

kotlin - 如何仅映射序列中的某些项目而忽略其他项目

android - 如何从协程范围返回值

ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序 - ios google 登录

ios - 澄清 Swift 中类的可失败初始化器

ios - 后台位置更新会导致应用程序强制终止吗?

ios - WatchKit 菜单项未在真实设备上显示

android - Kotlin 崩溃无法将提供的符号转换为 Dependency 类型的对象 : org. jetbrains.kotlin.gradle.dsl.KotlinProjectExtension_Decorated

ios - 找不到支持键盘 type 4 的键盘 iPhone-PortraitChoco-NumberPad

xcode - 使用命令行向 Xcode 项目添加库/框架?

ios - 在物理设备上运行时找不到 -lBugsnagReactNative 的库