【发布时间】:2020-09-21 19:54:07
【问题描述】:
我使用 Kotlin Multiplatform 为 iOS 和 Android 创建了一个共享库,并且一切正常,直到我没有将 Xcode 更新到 12.0
当我将 Xcode 更新到 12.0 时,框架停止在真实设备 (iphone) 上工作,但在模拟器上工作
我的摇篮
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-android-extensions")
}
group = "com.example.multiplatform_android_ios"
version = "1.0-SNAPSHOT"
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
}
kotlin {
android()
ios {
binaries {
framework {
baseName = "shared"
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation("com.google.android.material:material:1.2.0")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.12")
}
}
val iosMain by getting
val iosTest by getting
}
}
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 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)
Xcode 12.0 安卓工作室 4.1 RC 3 Kotlin 1.4.10
com.android.tools.build:gradle:4.1.0-rc03
【问题讨论】:
-
这里也一样。在我的情况下,真实设备也无法使用以下错误:Building for iOS,但链接和嵌入式框架“shared.framework”是为 iOS 模拟器构建的。
-
我刚刚按照此文档创建了一个新项目:kotlinlang.org/docs/mobile/getting-started.html,并且发生了同样的错误(在模拟器上工作,但不在真实设备上工作)。
-
我认为这与几天前向 Kotlin 问题跟踪器报告的问题相同。请看一下here
-
@pauminku 检查答案
-
@ArtyomDegtyarev 是的,我知道 kotlin 问题
标签: android ios kotlin-multiplatform