Android Studio KMM 应用程序项目 - 为 ios 平台构建失败

问题描述 投票:0回答:2

我是 KMM 的新手,刚刚在 Macbook M1 Pro 上创建了一个新的 KMM 应用程序项目。没有代码更改,这只是我正在使用的 hello world 应用程序。我已经能够成功构建 Android 平台的项目,并且它在 Android 模拟器上运行良好。但是,当我尝试为 ios 平台构建它时,它失败并显示以下错误消息:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':shared'.
> The project must have a target for at least one of the following platforms: ios_simulator_arm64.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 553ms
** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution [CP-User]\ Build\ shared /Users/manajit/Projects/Learning/App/KMMExperiment/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-4552119A071AC6BAB7327E6434237EC3.sh (in target 'shared' from project 'Pods')
(1 failure)
Command PhaseScriptExecution failed with a nonzero exit code.
ios cocoapods kotlin-multiplatform
2个回答
6
投票

目前,KMM 插件创建的基础应用程序已注释掉对 ARM 模拟器的支持,因为有些库尚不支持它。这很可能是由 Ktor 造成的,它最近才添加了支持。

转到

shared/build.gradle.kts
并取消注释所有包含
iosSimulatorArm64
的行。


0
投票

我通过将

arm64
放入排除架构中解决了这个问题。

目标 > 构建设置 > 排除的架构 > 为每个方案添加

Any iOS Simulator SDK
,值为
arm64
,如图所示:

然后通过 Xcode 或点击命令删除派生数据:

rm -rf ~/Library/Developer/Xcode/DerivedData

© www.soinside.com 2019 - 2024. All rights reserved.