Kotlin/kotlin-examples

ShardeCode: Creating iOS Application error.

Opened this issue · 5 comments

I've followed the tutorial to share kotlin code between android and ios . I have encountered a number of errors and now, I have found an error in Creating iOS Application, when I try to compile the gradle of sharedcode specifically

Executing tasks: [build]

Configure project :SharedCode
Kotlin Multiplatform Projects are an experimental feature.

Task :SharedCode:androidProcessResources NO-SOURCE
Task :SharedCode:compileKotlinAndroid UP-TO-DATE
Task :SharedCode:androidMainClasses UP-TO-DATE
Task :SharedCode:androidJar UP-TO-DATE

Task :SharedCode:compileKotlinIOS
xcrun: error: SDK "iphonesimulator" cannot be located
xcrun: error: SDK "iphonesimulator" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphonesimulator'
exception: org.jetbrains.kotlin.konan.KonanExternalToolFailure: The /usr/bin/xcrun command returned non-zero exit code: 1.
at org.jetbrains.kotlin.konan.exec.Command.handleExitCode(ExecuteCommand.kt:100)
at org.jetbrains.kotlin.konan.exec.Command.getOutputLines(ExecuteCommand.kt:91)
at org.jetbrains.kotlin.konan.exec.Command.getOutputLines$default(ExecuteCommand.kt:72)
at org.jetbrains.kotlin.konan.target.CurrentXcode.xcrun(Xcode.kt:54)
at org.jetbrains.kotlin.konan.target.CurrentXcode.getSdkPath(Xcode.kt:56)
at org.jetbrains.kotlin.konan.target.CurrentXcode.access$getSdkPath(Xcode.kt:37)
at org.jetbrains.kotlin.konan.target.CurrentXcode$iphonesimulatorSdk$2.invoke(Xcode.kt:46)
at org.jetbrains.kotlin.konan.target.CurrentXcode$iphonesimulatorSdk$2.invoke(Xcode.kt:37)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.jetbrains.kotlin.konan.target.CurrentXcode.getIphonesimulatorSdk(Xcode.kt)
at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl.getAbsoluteTargetSysRoot(Apple.kt:36)
at org.jetbrains.kotlin.konan.target.ClangArgs.getAbsoluteTargetSysRoot(ClangArgs.kt)
at org.jetbrains.kotlin.konan.target.ClangArgs.getSpecificClangArgs(ClangArgs.kt:65)
at org.jetbrains.kotlin.konan.target.ClangArgs.(ClangArgs.kt:231)
at org.jetbrains.kotlin.konan.target.Platform$clang$2.invoke(Platform.kt:25)
at org.jetbrains.kotlin.konan.target.Platform$clang$2.invoke(Platform.kt:21)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.jetbrains.kotlin.konan.target.Platform.getClang(Platform.kt)
at org.jetbrains.kotlin.backend.konan.KonanConfig.(KonanConfig.kt:56)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:60)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:35)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:96)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:71)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:39)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:204)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:196)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:217)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:208)
at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:37)
at org.jetbrains.kotlin.konan.util.UtilKt.profile(Util.kt:31)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:210)
at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:279)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:16)

Task :SharedCode:compileKotlinIOS FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':SharedCode:compileKotlinIOS'.

Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

  • 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 10s
3 actionable tasks: 1 executed, 2 up-to-date
12:03:53: Task execution finished 'build'.

I have same error. please help me!!!

Task :SharedCode:compileKotlinIOS FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':SharedCode:compileKotlinIOS'.

Process 'command '/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

  • 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.

Reopen.

Hi, Danilo!

You need to run this command on terminal:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

Because if you update xcode version, the path is not the same as before.

After, you can run gradle.

Hi, Rodrigo
man, you just saved me, this worked perfectly for me, thank you very much.

Solved by the solution proposed by Rodrigo, just above.

Hi, Danilo!

You need to run this command on terminal:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

Because if you update xcode version, the path is not the same as before.

After, you can run gradle.