Kotlin-native: xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH

Created on 19 Nov 2019  路  5Comments  路  Source: JetBrains/kotlin-native

I tried a hello world example from IntellijIdea with 1.3.60. Got this error.

`

Task :compileKotlinMacos
xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
e: org.jetbrains.kotlin.konan.KonanExternalToolFailure: The /usr/bin/xcrun command returned non-zero exit code: 72.
output:
at org.jetbrains.kotlin.konan.exec.Command.handleExitCode(ExecuteCommand.kt:105)
at org.jetbrains.kotlin.konan.exec.Command.getResult(ExecuteCommand.kt:94)
at org.jetbrains.kotlin.konan.exec.Command.getOutputLines(ExecuteCommand.kt:73)
at org.jetbrains.kotlin.konan.exec.Command.getOutputLines$default(ExecuteCommand.kt:72)
at org.jetbrains.kotlin.konan.target.CurrentXcode.xcrun(Xcode.kt:73)
at org.jetbrains.kotlin.konan.target.CurrentXcode.access$xcrun(Xcode.kt:43)
at org.jetbrains.kotlin.konan.target.CurrentXcode$version$2.invoke(Xcode.kt:68)
at org.jetbrains.kotlin.konan.target.CurrentXcode$version$2.invoke(Xcode.kt:43)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.jetbrains.kotlin.konan.target.CurrentXcode.getVersion(Xcode.kt)
at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl.(Apple.kt:70)
at org.jetbrains.kotlin.konan.target.ConfigurablesImplKt.loadConfigurables(ConfigurablesImpl.kt:52)
at org.jetbrains.kotlin.konan.target.PlatformManager.(Platform.kt:36)
at org.jetbrains.kotlin.konan.target.PlatformManager.(Platform.kt:32)
at org.jetbrains.kotlin.backend.konan.KonanConfig.(KonanConfig.kt:38)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:60)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:34)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:82)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:50)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:215)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:207)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:225)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:222)
at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:27)
at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:21)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:224)
at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:304)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:16)

Task :compileKotlinMacos FAILED

`
with 1.3.50 this code works well

Most helpful comment

A couple of years ago, it used to be possible to install just the command line tool without Xcode:

xcode-select --install # or download from https://developer.apple.com/download/more/
sudo xcode-select --switch /Library/Developer/CommandLineTools

Now that doesn't fix this error, in spite of both xcodebuild and xcrun being installed and on the path.

Xcode is a huge install, is largely useless for me, and it messes with file associations, so I really don't want to install it. If this can't be fixed, I think I'll opt for building for macOS on a build server instead of cluttering my development PC with Xcode.

EDIT: I also tried to symlink xcodebuild and xcrun to /Library/Developer/CommandLineTools/usr/bin, but that didn't work either. It seems like gsilvapt is right in that there are some issues with the $PATH that the build plugin sees.

All 5 comments

Please check the Xcode version and make sure that Command Line Tools are installed.

I didn't have any xcode installation at all) Of course I installed it. Now it works.. but I think we need to prepare some doc like 'migration guide' or 'required deps' because before this i developed my program without xcode. and it compiled successfully,

Just to let you guys know I just faced this issue and only worked after installing XCode and selecting the Command Line Tools in the Preferences menu, although the command line tools were already installed. Does this mean there are actual issues with $PATH?

A couple of years ago, it used to be possible to install just the command line tool without Xcode:

xcode-select --install # or download from https://developer.apple.com/download/more/
sudo xcode-select --switch /Library/Developer/CommandLineTools

Now that doesn't fix this error, in spite of both xcodebuild and xcrun being installed and on the path.

Xcode is a huge install, is largely useless for me, and it messes with file associations, so I really don't want to install it. If this can't be fixed, I think I'll opt for building for macOS on a build server instead of cluttering my development PC with Xcode.

EDIT: I also tried to symlink xcodebuild and xcrun to /Library/Developer/CommandLineTools/usr/bin, but that didn't work either. It seems like gsilvapt is right in that there are some issues with the $PATH that the build plugin sees.

Out of curiosity what is it about kotlin-native that requires XCode itself? I am not aware of another compiler that has this kind of runtime dependency.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brettwillis picture brettwillis  路  4Comments

Marcopohlo picture Marcopohlo  路  4Comments

SBNTT picture SBNTT  路  4Comments

barsan-md picture barsan-md  路  4Comments

tarek360 picture tarek360  路  4Comments