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

Viewed 535

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?

3 Answers

I had the same issue but this solution helped me:

From KMM pluging you will obtain (on dependencies):

Change this:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")

To this:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")

After some code review from 2-3 months old KMM examples project and comparing them with new ones, I found out a solution for this build failure when trying to run iosApp on Ios Simulators, just apply this change to build.gradle.kts on root project:

From KMM pluging you will obtain (on dependencies):

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")

Change it to:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")

And that's it, problem solve. I hope someone on Jetbrains can solve this problem in future updates of KMM plugin.

08/30/2020:

It seems that Jetbrains has correct some issues and now you can build and run a KMM project with version 1.7.10, the last stable version at this time.

By the way, if you have any trouble is worthy to check this stack overflow post about JDK version used by Android Studio : How to set or change the default Java (JDK) version on macOS?

Multiplatform error when building iosApp: Command PhaseScriptExecution failed with a nonzero exit code

What i found to be the solution was to uncomment the "iosSimulatorArm64()" in the "build.gradle.kts(:shared)".

kotlin {
android()
iosX64()
iosArm64()
iosSimulatorArm64() //sure all ios dependencies support this target

cocoapods {
    summary = "Some description for the Shared Module"
    homepage = "Link to the Shared Module homepage"
    ios.deploymentTarget = "14.1"
    podfile = project.file("../iosLink/Podfile")
    framework {
        baseName = "shared"
    }
}

sourceSets {
    val commonMain by getting
    val commonTest by getting {
        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
        }
    }
    val androidMain by getting
    val androidTest by getting {
        dependencies {
            implementation(kotlin("test-junit"))
            implementation("junit:junit:4.13.2")
        }
    }
    val iosX64Main by getting
    val iosArm64Main by getting
    val iosSimulatorArm64Main by getting
    val iosMain by creating {
        dependsOn(commonMain)
        iosX64Main.dependsOn(this)
        iosArm64Main.dependsOn(this)
        iosSimulatorArm64Main.dependsOn(this)
    }
    val iosX64Test by getting
    val iosArm64Test by getting
    //val iosSimulatorArm64Test by getting
    val iosTest by creating {
        dependsOn(commonTest)
        iosX64Test.dependsOn(this)
        iosArm64Test.dependsOn(this)
        //iosSimulatorArm64Test.dependsOn(this)
    }
}

}

Related