Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KMM in Android Studio build return Command PhaseScriptExecution failed with a nonzero exit code

I've just created a new KMM project through out KMM Plugin, but I can't run or even debug in Xcode iosApp part of the project. When I try to run iosApp from Android Studio, the build process fails (Command PhaseScriptExecution failed with nonzero exit code)

The final lines of building was:

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 8s 1 actionable task: 1 executed Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **

The following build commands failed: PhaseScriptExecution Run\ Script /Users/tamegajr/AndroidStudioProjects/TesteKMM5/build/ios/iosApp.build/Release-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (1 failure)

Can anyone help to solve this problem?

like image 795
tamegajr Avatar asked May 06 '26 19:05

tamegajr


1 Answers

In my case XCode's JAVA_HOME variable caused the problem.

  1. Open project on XCode
  2. Open iosApp.xcodeproj on sidepanel
  3. Select BuildPhases
  4. Expand "Run Script"

Add this two lines into Build Script, before gradlew tasks. (I've used Android Studio's built-in JDK. If you want to use another JDK, you should change JAVA_HOME and JDK_HOME paths in code below.)

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/
export JDK_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/

Your final Build Script should be like this;

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/
export JDK_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/

cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
like image 150
Emirhan Soylu Avatar answered May 09 '26 01:05

Emirhan Soylu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!