Hello, everyone :wave:. I’ve just created a new KM...
# multiplatform
h
Hello, everyone 👋. I’ve just created a new KMM project, but when tried to open it on XCode it shows the following error:
Copy code
The operation could''t be completed. Unable to locate a Java Runtime.
Please visit <http://www.java.com> for information on installing Java.

Command PhaseScriptExecution failed with a nonzero exit code
From Android Studio I even can run it on an iOS emulator, but I can’t get preview or run it from xcode. Anyone to help me on that 😄 ?
oh, just some details: • I use
sdkman
to manage my sdks (including JDK) and I installed through it • if I type:
javac -version
it shows the correct version that I’ve installed, but if I type:
/usr/libexec/java_home -V
it shows
Copy code
The operation couldn't be completed. Unable to locate a Java Runtime.
Which is the same message that appears on xcode logs. Do you think it has something to do with JDK/JRE path?
a
in a terminal, does
echo $JAVA_HOME
return anything? I don't use XCode, but my guess is that it
JAVA_HOME
isn't set, or XCode has some other way of setting it
j
I don't have anything in JAVA_HOME but my java executable is in /usr/bin. Can you type which java and see if the path is what you expect? Are you certain you have a JDK installed and not a JRE?
h
echo $JAVA_HOME
returns: /Users/henriquehorbovyi/.sdkman/candidates/java/current
which java
also returns /Users/henriquehorbovyi/.sdkman/candidates/java/current/bin/java
j
You may need to set java home then to point to it, and as I haven't used sdkman you can look at the comments here. https://github.com/sdkman/sdkman-cli/issues/431
h
Well, I found out a solution The problem: • xcode was expecting that this program /usr/libexec/java_home (which is the default for the OS) would return the path of my installed java • But I have installed java via sdkman and
java_home
can only identify a java path if it would come from a macOS normal installation (if I had downloaded a jdk.dmg for example) How I solved: • I solved the problem by adding a custom path called JAVA_HOME inside xcode locations preferences
👍 1
235 Views