KMM构建iOS失败:linkDebugFrameworkIosSimulatorArm64任务报错
Kotlin Multiplatform iOS构建报错:linkDebugFramework与PhaseScriptExecution运行脚本错误
问题详情
构建Kotlin Multiplatform(KMM)iOS应用时,无论是通过Xcode还是Android Studio,都会触发以下错误:
linkDebugFrameworkIosSimulatorArm64任务执行失败,核心报错为ld: unknown options: -ios_simulator_version_min -sdk_version- 伴随PhaseScriptExecution运行脚本任务失败
完整报错堆栈:
> Task :shared:linkDebugFrameworkIosSimulatorArm64 FAILED error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1. output: ld: unknown options: -ios_simulator_version_min -sdk_version error: Compilation finished with errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':shared:linkDebugFrameworkIosSimulatorArm64'. > Compilation finished with errors * 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 13s 2 actionable tasks: 1 executed, 1 up-to-date ** BUILD FAILED ** The following build commands failed: PhaseScriptExecution Run\ Script /Users/[user]/Desktop/[app]/build/ios/[app-name].build/Debug-iphonesimulator/[app-name].build/Script-7555FFB5242A651A00829871.sh (in target '[app-name]' from project '[app-name]') (1 failure)
已尝试的无效解决方法
- 设置xcodebuild命令行版本
- 清理iOS构建文件夹
- 重新安装Xcode和Android Studio
- 清理Gradle缓存并重建Gradle
- 降级Xcode
有效解决方案
更新项目根目录下build.gradle.kts中的插件版本,使用以下配置:
id("com.android.application").version("8.1.0").apply(false) id("com.android.library").version("8.1.0").apply(false) id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin").version("2.0.1").apply(false) kotlin("android").version("1.9.10").apply(false) kotlin("multiplatform").version("1.9.10").apply(false) kotlin("plugin.serialization").version("1.9.10").apply(false)
内容的提问来源于stack exchange,提问作者hokobaro
相关产品推荐
相关产品推荐

