Skip to content
Snippets Groups Projects
Commit d579dbb4 authored by Martin Afanasjew's avatar Martin Afanasjew
Browse files

xcode: avoid invoking 'xcodebuild -version' twice


This primarily benefits CLT-only systems where invoking the `xcodebuild`
wrapper in `/usr/bin` will fail (twice) with the following message:

  xcode-select: error: tool 'xcodebuild' requires Xcode, but active
  developer directory '/Library/Developer/CommandLineTools' is a command
  line tools instance

Closes #198.

Signed-off-by: default avatarMartin Afanasjew <martin@afanasjew.de>
parent 5ee797eb
No related branches found
No related tags found
No related merge requests found
......@@ -81,14 +81,19 @@ module OS
return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed?
%W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path|
if File.file? path
Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/
return $1 if $1
%W[
#{prefix}/usr/bin/xcodebuild
#{which("xcodebuild")}
].uniq.each do |xcodebuild_path|
if File.executable? xcodebuild_path
xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version")
next unless $?.success?
xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1]
return xcode_version if xcode_version
# Xcode 2.x's xcodebuild has a different version string
Utils.popen_read(path, "-version") =~ /DevToolsCore-(\d+\.\d)/
case $1
case xcodebuild_output[/DevToolsCore-(\d+\.\d)/, 1]
when "515.0" then return "2.0"
when "798.0" then return "2.5"
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment