【问题标题】:Kotlin Multiplatform Mobile unable to run on iOS: Execution failed for task ':shared:compileKotlinIosX64'Kotlin Multiplatform Mobile 无法在 iOS 上运行:任务 ':shared:compileKotlinIosX64' 执行失败
【发布时间】:2021-05-12 18:09:53
【问题描述】:

我在 KMM 中创建了 fresh project(Hello World),然后是他们的官方网站。在 android 中它运行顺利,但是当我尝试在 XCode 中运行时,它会给出错误,因为 I am unable to build / run the xcode project。我附上了我的错误的截图和日志。不知何故,Xcode 方案没有在 KMM 平台中生成,这就是我的猜测。 谁能帮我理解我错过了什么? 任何帮助都将不胜感激。

Following is my dev env:

Xcode 11.4.1
Android 4.1.2
Kotling Plugin version 1.4.30 (stable)
KMM 0.2.0```


XCode Logs:

> Task :shared:compileKotlinIosX64
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
Extracting dependency: /Users/fatin/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos.tar.gz into /Users/fatin/.konan/dependencies
e: java.lang.RuntimeException: Cannot extract archive with dependency: /Users/fatin/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos.tar.gz.

> Task :shared:compileKotlinIosX64 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:compileKotlinIosX64'.
> 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 7s
1 actionable task: 1 executed
Command PhaseScriptExecution failed with a nonzero exit code ```
[![enter image description here][3]][3]


【问题讨论】:

  • 你能分享这个项目吗?可能是您的某些依赖项没有 iosX64 目标,或者您的实际实现不适用于此目标
  • @NagyRobi 还没有添加任何花哨的东西,但仍然如此。这是您可以通过的github链接。 github.com/fatinWasta/kmm_demo
  • @FatinWasta 我刚刚在 A.S - 4.1.2 中编译了您的应用程序,它适用于 android 和 iOS
  • 您使用哪个版本的 android 和 xcode ?
  • 您能否检查一下您是否在 Xcode 中设置了Command Line Tools?您可以通过以下方式查看:- Xcode -> Preferences -> Locations -> Command Line tools

标签: ios xcode kotlin kotlin-multiplatform


【解决方案1】:

我为此联系了社区并最终找到了解决方案。这是我提出并解决了这个问题的link to that issue

如果其他人遇到同样的问题,这主要是 kotlin 文件损坏的原因。 还可以尝试按照 cmets 在 XCode 中检查您的命令行工具。

希望这对某人有所帮助。干杯。

【讨论】:

  • 解决办法是什么?
  • @IgorGanapolsky 你能看看我添加到这个答案的链接吗?
  • @FatinWasta 您应该在此处添加答案,因为无法保证您添加的链接将来会存在。
【解决方案2】:

如果项目从 Xcode 打开后没有立即运行,并且显示缺少共享框架,则尝试使用终端为 iOS 平台生成共享框架。导航到项目文件夹并执行 命令:./gradlew packForXcode 现在共享框架应该有一个 xcode-frameworks 产品,您应该能够通过 Xcode 构建和运行项目。

【讨论】:

  • 它无法构建布拉德利 :(
【解决方案3】:

如果有两个库,其中一个库是针对另一个库的与项目中当前使用的版本不同的版本编译的,则可能会发生这种情况。请检查项目配置是否正确,依赖版本是否一致。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-11
    • 2020-11-09
    • 1970-01-01
    • 2018-11-14
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多