as Apple announced that Xcode Cloud is now available for all developers, I tried to set it up for a Kotlin Multiplatform project. The start was a little bit hard tbh. Currently I am facing following problem during a simple test action:
The operation couldn’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
So I tried to install a jdk during the ci_post_clone.sh phase. The output of java -version after the installation on the Xcode Cloud is the following:
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
Installed java
also ./gradlew -v output:
Showing All Messages
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.2 (Oracle Corporation 17.0.2+8-86)
OS: Mac OS X 12.4 x86_64
Nevertheless, I still get the same error. Is this maybe a restriction by Apple?
Any ideas?
Basically we install a JDK through a tar ball into the project folder using
ci_post_clone.sh. We choose the project folder because we have control over this directory, contrary to for example installing java through brew (where you would have to symlink the java install into a system directory, which isn't allowed (https://developer.apple.com/documentation/xcode/making-dependencies-available-to-xcode-cloud)This is the script we use:
After running the script for the first time, the logs will print the last
echoin the script to indicate where the Java SDK is located. This value should be set asJAVA_HOMEin the "Environment Variables" inside the "Edit" section of the workflow.After that, the build will work with the Java SDK and build the artifacts.