Hi. New KMM project generated in Android Studio. F...
# multiplatform
a
Hi. New KMM project generated in Android Studio. First iosApp run fails. Any clues?
Copy code
** BUILD FAILED **


The following build commands failed:	

PhaseScriptExecution Run\ Script /Users/adrianwitaszak/Projects/KMP/MyApplication/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')

> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Could not initialize class llvm.llvm

 * Source files: 
 * Compiler version info: Konan: 1.6.10 / Kotlin: 1.6.10
 * Output kind: FRAMEWORK

e: java.lang.NoClassDefFoundError: Could not initialize class llvm.llvm
b
As in "if you immediately rerun it again it boots up fine"?
a
No it fails every time i try to run iOS App
b
Ah, gotcha. The word "first" confused me.
a
basicaly i create new kmm project, run ios app and it fails
b
Yeah, I get that now. To be honest broken IDE project templates for KMP are a norm these days. Most of them usually require some tinkering to work after initialisation.
Sounds like your knative did not install properly. Try removing ~/.konan and running from the terminal again.
a
ok. removed .konan. waiting for kotlin compiler to be installed
still failing
Copy code
> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Could not initialize class llvm.llvm

 * Source files: 
 * Compiler version info: Konan: 1.6.10 / Kotlin: 1.6.10
 * Output kind: FRAMEWORK
Copy code
e: java.lang.NoClassDefFoundError: Could not initialize class llvm.llvm
Copy code
BUILD FAILED in 1s
2 actionable tasks: 1 executed, 1 up-to-date
Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution Run\ Script /Users/adrianwitaszak/Projects/KMP/MyApplication/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
(1 failure)
b
Hmm, can you try downgrading to 1.6.0
a
ok i’ll do whatever it needs to get it working :)
Copy code
> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Can't load library: /Users/adrianwitaszak/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.0/konan/nativelib/13622981358584302003/libllvmstubs.dylib

 * Source files: 
 * Compiler version info: Konan: 1.6.0 / Kotlin: 1.6.0
 * Output kind: FRAMEWORK

e: java.lang.UnsatisfiedLinkError: Can't load library: /Users/adrianwitaszak/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.0/konan/nativelib/13622981358584302003/libllvmstubs.dylib
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:linkDebugFrameworkIosX64'.
> Compilation finished with errors

BUILD FAILED in 7s
2 actionable tasks: 2 executed
Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution Run\ Script /Users/adrianwitaszak/Projects/KMP/MyApplication/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
(1 failure)
b
Ok, I'm just spitballing here, but here are few things to check: • Try different jvm versions (8 vs 11) • Reinstall xcode cmdline tools • Reinstall ios simulator (emulator?) • Downgrade xcode itself if you can
All that after bumping kotlin version back to latest
If nothing works, wait until the experts wake up and answer tomorrow 😀
🆗 1
a
to what version of Xcode i should downgrade to?
b
Just one version minor version down. Kotlin is usually quite up to date with the latest xcode changes
a
Hello! I've found two similar issues in our tracker: https://youtrack.jetbrains.com/issue/KT-47309 & https://youtrack.jetbrains.com/issue/KT-43596. The former is related to wrong JDK in the envvar, the latter also shows a problem that was relevant for Arm64 Macs. Could you please check which JDKs do you have locally, and which one is being used in this Gradle run from Xcode. Please also note, that in some cases running Gradle from IDE or Terminal one might have JAVA_HOME different from the one being set when running Gradle from Xcode
Run Script
.
a
Hi. I decided to wipe out my MacBook and reinstall MacOS. Re-downloading everything now. What's Java version I should get? Java 11?
a
I think its fine to start with Java 11. There is no strict requirement on versions, I still believe that the problem was caused by Xcode's run script unable to find jdk in general.
a
still getting the same errors:
Copy code
The following build commands failed:
	PhaseScriptExecution Run\ Script /Users/adrianwitaszak/Projects/KMP/testapp/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
(1 failure)
Copy code
> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Could not initialize class llvm.llvm

 * Source files: 
 * Compiler version info: Konan: 1.6.10 / Kotlin: 1.6.10
 * Output kind: FRAMEWORK

e: java.lang.NoClassDefFoundError: Could not initialize class llvm.llvm
i’m on /Library/Java/JavaVirtualMachines/corretto-11.0.14.1/Contents/Home
tried java 15 as well
b
Hmm, i usually try to avoid exotic JDKs. Maybe try with openjdk before you put this to rest?
a
Have you checked that in the Run Script the result of “echo $JAVA_HOME” is the same as in terminal?
a
changed to openJdk 11:
Copy code
> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: /Users/adrianwitaszak/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/konan/nativelib/6012039609168293530/libllvmstubs.dylib: dlopen(/Users/adrianwitaszak/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/konan/nativelib/6012039609168293530/libllvmstubs.dylib, 0x0001): Library not loaded: @rpath/libc++.1.dylib
  Referenced from: /Users/adrianwitaszak/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/konan/nativelib/6012039609168293530/libllvmstubs.dylib
  Reason: tried: '/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home/lib/server/./libc++.1.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home/lib/server/../libc++.1.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home/bin/../lib/jli/libc++.1.dylib' (no such file)
adrianwitaszak@Adrians-MacBook-Pro testapp % echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home
i’m on: MacOS Monterei 12.3 Beta (21E5206e), Intel processor, Android Studio Dolphin | 2021.3.1 Canary 3 Xcode Version 13.2.1 (13C100) jdk-11.0.14
k
I got the same error after setting up and build Kotlin native project in IntelliJ 2022.1 EAP today. Tried and failed with 1.6.10 / 1.6.20-M1 / termurin-17 / oracle openjdk-17.
I suspect the latest macOS beta causes this issue. I’m also on macOS Monterey 12.3 Beta (21E5206e) and Xcode 13.2.1 (13C100)
s
Hi! Could you please run the following commands
Copy code
install_name_tool -change @rpath/libc++.1.dylib /usr/lib/libc++.1.dylib ~/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/konan/nativelib/libllvmstubs.dylib
./gradlew --stop
and try to compile the project again? You might need to change the version in the Kotlin/Native path in the first command.
We were able to reproduce, investigate and fix the issue. The fix will be available with Kotlin 1.6.20-RC. The workaround I proposed above works for me. I would be glad if someone else confirmed this as well. See also https://youtrack.jetbrains.com/issue/KT-51359 for more details and a way to automate the workaround. Thank you all for the reports, btw!
2
a
It works!. Thank you very much for you help! Jetbrains is a great team!
🙏 1
👍 2
k
It also works for me. Thanks all!
s
Thank you for the confirmations!
478 Views