lib/xcode/install.rb in xcode-install-2.4.0 vs lib/xcode/install.rb in xcode-install-2.4.1

- old
+ new

@@ -295,11 +295,11 @@ installed = installed_versions.map(&:version) xcodes_list.map { |x| installed.include?(x) ? "#{x} (installed)" : x }.join("\n") end def list - list_annotated(list_versions.sort) + list_annotated(list_versions.sort_by(&:to_f)) end def rm_list_cache FileUtils.rm_f(LIST_FILE) end @@ -379,15 +379,17 @@ xcodes end def installed - unless (`mdutil -s /` =~ /disabled/).nil? - raise 'Please enable Spotlight indexing for /Applications.' + result = `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n") + if result.empty? + result = `find /Applications -name '*.app' -type d -maxdepth 1 -exec sh -c \ + 'if [ "$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" \ + "{}/Contents/Info.plist" 2>/dev/null)" == "com.apple.dt.Xcode" ]; then echo "{}"; fi' ';'`.split("\n") end - - `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n") + result end def parse_seedlist(seedlist) fail Informative, seedlist['resultString'] unless seedlist['resultCode'].eql? 0 @@ -626,10 +628,10 @@ end def install_components # starting with Xcode 9, we have `xcodebuild -runFirstLaunch` available to do package # postinstalls using a documented option - if Gem::Version.new(@version) >= Gem::Version.new('9') + if Gem::Version.new(version) >= Gem::Version.new('9') `sudo #{@path}/Contents/Developer/usr/bin/xcodebuild -runFirstLaunch` else Dir.glob("#{@path}/Contents/Resources/Packages/*.pkg").each do |pkg| `sudo installer -pkg #{pkg} -target /` end