我创建了一个项目来演示 Kotlin Multiplatform Mobile。我在 Android 和 iOS 两种设备上成功构建并运行了它。之后,我在 iOS 上重新运行了该项目。它有一个错误。
> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
FAILURE: Build failed with an exception.
* What went wrong:
Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 1s
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Volumes/Data/ProjectsKMM/DemoNetworkAPI/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh
(1 failure)
这是我在 Github 上的项目单击此处。请看一下并帮我找出错误。
提前致谢。
您需要至少使用 Kotlin 1.5.20 才能使用
embedAndSignAppleFrameworkForXcode
(更多信息见 https://blog.jetbrains.com/kotlin/2021/07/multiplatform-gradle-plugin-improved-for-connecting -kmm-模块/)
embedAndSignPodAppleFrameworkForXcode
为我工作
Kotlin 插件版本:212-1.7.10-release-333-AS5457.46
这是 xcode/Android Studio 关于失败任务的建议
Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'. Some candidates are: 'embedAndSignPodAppleFrameworkForXcode'.
我将
composeApp
模块重命名为 app_presentation
所以我必须修复如何在 Xcode 中运行任务
当我将此行更改为
./gradlew :app_presentation:embedAndSignAppleFrameworkForXcode
时,我解决了我的问题