Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/xcode/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,10 @@ def install_components
`touch #{cache_dir}com.apple.dt.Xcode.InstallCheckCache_#{osx_build_version}_#{tools_version}`
end

# This method might take a few ms, this could be improved by implementing https://github.com/KrauseFx/xcode-install/issues/273
def fetch_version
output = `DEVELOPER_DIR='' "#{@path}/Contents/Developer/usr/bin/xcodebuild" -version`
output = `/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "#{@path}/Contents/version.plist"`
return '0.0' if output.nil? || output.empty? # ¯\_(ツ)_/¯
output.split("\n").first.split(' ')[1]
output.sub("\n", '')
end

def verify_integrity
Expand Down
4 changes: 2 additions & 2 deletions spec/installed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module XcodeInstall

describe InstalledXcode do
it 'finds the current Xcode version with whitespace chars' do
InstalledXcode.any_instance.expects(:`).with("DEVELOPER_DIR='' \"#{xcode_path}/Contents/Developer/usr/bin/xcodebuild\" -version").returns("Xcode 6.3.1\nBuild version 6D1002")
InstalledXcode.any_instance.expects(:`).with("/usr/libexec/PlistBuddy -c \"Print :CFBundleShortVersionString\" \"#{xcode_path}/Contents/version.plist\"").returns('6.3.1')
installed = InstalledXcode.new(xcode_path)
installed.version.should == '6.3.1'
end

it 'is robust against broken Xcode installations' do
InstalledXcode.any_instance.expects(:`).with("DEVELOPER_DIR='' \"#{xcode_path}/Contents/Developer/usr/bin/xcodebuild\" -version").returns(nil)
InstalledXcode.any_instance.expects(:`).with("/usr/libexec/PlistBuddy -c \"Print :CFBundleShortVersionString\" \"#{xcode_path}/Contents/version.plist\"").returns(nil)
installed = InstalledXcode.new(xcode_path)
installed.version.should == '0.0'
end
Expand Down