android - 框架“shared.framework”缺少此目标所需的一个或多个架构:arm64。Xcode 12.0 科特林 1.4.10
问题描述
我使用 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 Android Studio 4.1 RC 3 Kotlin 1.4.10
com.android.tools.build:gradle:4.1.0-rc03
解决方案
我也遇到了同样的问题,按照以下步骤解决:
- 关闭 Android Studio
- 删除共享模块内的构建文件夹
- 现在在 Xcode 中打开 iOS App 并插入您的设备
- 确保您已在 Xcode 项目的构建阶段运行此脚本
cd "$SRCROOT/.."
./gradlew :shared:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}
- 现在构建项目,它将成功
推荐阅读
- java - 如何使用 putExtra() 和 getExtras() 代码获取 int 值?
- dart - Flutter 从 Firebase 存储中获取下载 URL
- python - 使用 Django / virtualenv 运行 celery 时找不到“__main__”模块
- c# - 创建宏时如何区分两个同名窗口
- angular - NGRX 角载荷或无载荷
- node.js - 更新 apollo-server-lambda npm 后,无服务器 lambda 不起作用
- android - 约束 2 个视图时的 ConstraintLayout 奇怪的属性行为
- java - 尝试读取文件时出现奇怪的 NoSuchFileException
- javascript - javascript中日期范围内的每小时分钟数
- html - 使用 response.redirect 传递数据库值