Kotlin Multiplatform Mobile unable to run on iOS: Execution failed for task ':shared:compileKotlinIosX64'
Asked Answered
B

3

13

I have created fresh project(Hello World) in KMM followed by their official website. In android it works smooth but when I am trying to run in XCode it's giving errors because of which I am unable to build / run the xcode project. I have attached screenshots and logs for my errors. Somehow xcode scheme is not getting generated in the KMM platform that's what I am guessing. Can anyone please help me understand what am I missing? Any help would be appriciated. Screenshot of android studio build settings Screenshot of blank iOS scheme XCode error log 1 XCode error log 2

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]


Begird answered 9/2, 2021 at 5:24 Comment(19)
Can you share the project? It might be that some of your dependencies don't have an iosX64 target or your actual implementations are not working for this targetNikitanikki
@NagyRobi nothing fancy added yet but still. Here is the github link which you can go through. github.com/fatinWasta/kmm_demoBegird
@FatinWasta I just compiled your app in A.S - 4.1.2 and it works fine for both android and iOSZacharie
Which version are you using for android and for xcode ?Zacharie
Also can you please check if you have set Command Line Tools in your Xcode ? You can check from :- Xcode -> Preferences -> Locations -> Command Line tools.Zacharie
@MohammedHanif. Following is my dev env: Xcode 11.4.1 cmd lines tools are 11.4.1 Android 4.1.2 Kotling Plugin version 1.4.30 (stable) KMM 0.2.0```Begird
maybe this can help looks similar to me :- #64031101Zacharie
@MohammedHanif. above link is when there are two xcodes and cmd line tool couldnt decide about which to follow. I have only one. Can you please let me know your system env?Begird
@FatinWasta Xcode version - 12.0.1 same for cmd tools all others are same as yours.Zacharie
did that help you ?Zacharie
@MohammedHanif. no it didn't. :(Begird
does running same project from Xcode itself works or not ?Zacharie
@MohammedHanif. nope it doesn't. I have added the screenshots what happens if I run it from XCode.Begird
Does this answer your question? How to configure an iOS Application for Kotlin Multiplatform in Android Studio?Sailor
If this does not work even after following the solution on youtrack, anyone can try this answerSalvatore
@FatinWasta did u find a solution?Necktie
the same. Did anyone find a solution?Necktie
Hey Guys, mods deleted my answere where I shared the details. This issue happened to me cause of corrupted kotlin files, you can try reinstalling kotlin. Also try checking your cmd line tools in XCode as per comments. Here is ticket which I created on jetbrains for support. youtrack.jetbrains.com/issue/KT-44805Begird
Solution: Deleted clang-llvm-apple-8.0.0-darwin-macos, Clean gradle Rebuild in Xcode. auto initiated download in /Users/fatin/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos (^ Took almost 5hrs to download, can be cause of my connection but not sure cause everything else loads well.) As soon as file is downloaded succesively, XCode build succeeded. Now I can run in iOS sim via XCode.Begird
K
0

May be your project kotlin version is not matching with cached version. Try following techniques

  1. Delete the .konan directory from your home directory, it was hidden in mac.
  2. Check jdk version in the system and match it with your java version in project.
  3. Delete all the generated folders from project root, invalidate and restart the Android Studio.
Kendalkendall answered 20/7 at 7:22 Comment(0)
J
-2

If the project doesn't run right away even on opening it from Xcode and shows the shared framework is missing, Then try generating the shared framework for iOS platform using terminal. Navigate to the project folder and execute Command: ./gradlew packForXcode Now the shared framework should have a xcode-frameworks product and you should be able to build and run the project through Xcode.

Jugulate answered 12/2, 2021 at 12:27 Comment(0)
P
-3

This could happen if there are two libraries, where one library was compiled against the different version of the other library than the one currently used in the project. Please check that the project configuration is correct and has consistent versions of dependencies.

Petitionary answered 31/12, 2021 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.