xcode: use default location when possible.

Xcode can be installed anywhere but for most people it's in
`/Applications/Xcode.app` so just look there if `xcode-select` isn't
helpful before looking at Spotlight which can return weird results on
e.g. backup disks.

Fixes #1587.
This commit is contained in:
Mike McQuaid 2017-01-09 21:30:32 +00:00
parent 2c6915a48f
commit a17f38dd36

View File

@ -3,6 +3,7 @@ module OS
module Xcode
module_function
DEFAULT_BUNDLE_PATH = Pathname.new("/Applications/Xcode.app").freeze
BUNDLE_ID = "com.apple.dt.Xcode".freeze
OLD_BUNDLE_ID = "com.apple.Xcode".freeze
@ -67,11 +68,14 @@ module OS
Pathname.new("#{prefix}/Toolchains/XcodeDefault.xctoolchain")
end
# Ask Spotlight where Xcode is. If the user didn't install the
# helper tools and installed Xcode in a non-conventional place, this
# is our only option. See: https://superuser.com/questions/390757
def bundle_path
MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID)
# Use the default location if it exists.
return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist?
# Ask Spotlight where Xcode is. If the user didn't install the
# helper tools and installed Xcode in a non-conventional place, this
# is our only option. See: https://superuser.com/questions/390757
MacOS.app_with_bundle_id(BUNDLE_ID, OLD_BUNDLE_ID)
end
def installed?