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

2

13

I am working on a multiplatform app in Kotlin on Android Studio and when I try to run the app to an iOS simulator, I get this error:

The following build commands failed:

PhaseScriptExecution [CP-User]\ Build\ shared /Users/cjm/AndroidStudioProjects/GlobeMultiplatform/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-882AF45D8B8C4938AC461F4FBA0FE197.sh (in target 'shared' from project 'Pods')

The code in the build.gradle that sets the cocoa pods is this:

cocoapods {
    summary = "Shared"
    homepage = "Link to the Shared Module homepage"
    ios.deploymentTarget = "13"
    frameworkName = "shared"
    podfile = project.file("../iosApp/Podfile")
}

I ran pod install and it showed success but the build of the app still fails. How can I fix this error? What is causing this error? I am brand new to Kotlin and especially Kotlin Multiplatform so I apologize if this is a stupid question.

EDIT: Here's what Xcode says when running the app:

FAILURE: Build failed with an exception.

  • Where: Build file '/Users/cjm/AndroidStudioProjects/GlobeMultiplatform/androidApp/build.gradle.kts' line: 1

  • What went wrong: An exception occurred applying plugin request [id: 'com.android.application']

Failed to apply plugin 'com.android.internal.application'. Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing org.gradle.java.home in gradle.properties.

  • 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

Landing answered 24/10, 2021 at 5:22 Comment(7)
How do I do that?Landing
Actually unfold is only needed in Xcode, in AS you Build Output should contain al the information, it should be under PhaseScriptExecution [CP-User]\ Build\... lineCrowberry
This is all that it tells me... The following build commands failed: PhaseScriptExecution [CP-User]\ Build\ shared /Users/cjm/AndroidStudioProjects/GlobeMultiplatform/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-882AF45D8B8C4938AC461F4FBA0FE197.sh (in target 'shared' from project 'Pods') (1 failure)Landing
I just run my sample app with a build error, and I can see full output. It may be a bug in your case, try restarting AS. If this doesn't help, you can run it in Xcode, the logs there for sure will be available.Crowberry
I just added what Xcode says to the bottom of the question. What does this mean?Landing
This this answerCrowberry
This might be helpful. Update Your kotlin version to 1.8.20Skep
A
10

It seems that it tries to build your code with Java 1.8, you need a Java > 11 version.

I'd look into this or other guidelines to make sure the proper JDK version is used

Acidfast answered 24/10, 2021 at 10:3 Comment(0)
D
0

I also faced this error to run my KMP project to ios emulator. Just install the current version of Java: Java Download

After installing the problem was gone.

Diley answered 26/5 at 22:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.