diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 2a5a3a178c..43c83c14d3 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -297,8 +297,30 @@ module MacOS extend self def xcode_version @xcode_version ||= begin + raise unless system "/usr/bin/which -s xcodebuild" `xcodebuild -version 2>&1` =~ /Xcode (\d(\.\d)*)/ $1 + rescue + # for people who don't have xcodebuild installed due to using + # some variety of minimal installer, let's try and guess their + # Xcode version + case llvm_build_version.to_i + when 0..2063 then "3.1.0" + when 2064..2065 then "3.1.4" + when 2366..2325 + # we have no data for this range so we are guessing + "3.2.0" + when 2326 + # also applies to "3.2.3" + "3.2.4" + when 2327..2333 then "3.2.5" + when 2335 + # this build number applies to 3.2.6, 4.0 and 4.1 + # https://github.com/mxcl/homebrew/wiki/Xcode + "4.0" + else + "4.2" + end end end