xcode-install
xcode-install copied to clipboard
Xcode 8.3 not discovered by XcodeInstall::Installer#installed_versions
Steps to reproduce:
- Install Xcode 8.3
- Run in
irb
:
>> require 'xcode/install'
=> true
>> XcodeInstall::Installer.new.installed_versions
=> []
The problem appears to be with
mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"
This returns nothing if you run it after installing Xcode 8.3.
Is it possible that perhaps the Spotlight DB simply hadn't yet been fully updated?
I recently installed Xcode 8.3 and the mdfind
query you posted returns the application path on my system. But I could see that if the install took place and the command was run immediately afterwards, that the bundle couldn't be found.
People who would do mass installs of GarageBand, for example, used to run into a case where its bundle wouldn't be registered immediately after installation, and lsregister
had to be run manually to "force" registering it with LaunchServices. I realize Spotlight and LS aren't the same thing, but perhaps there's a similar thing going on here.
OK, that's good info - thanks @timsutton. 👍
Just to clarify that I didn't test the behaviour of a query immediately after an install - just hypothesizing based on prior experience with GarageBand, and also thinking that given the huge size and number of files in the Xcode bundle, that it could result in more lengthy background processing to fully scan its contents.
Yup, understood!
Seems something is a bit different with Xcode 8.3:
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app`
kMDItemCFBundleIdentifier = (null)
Previous version:
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.2.1.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"
Not here:
➜ ~ /usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' /Applications/Xcode-8.3.app/Contents/Info.plist
com.apple.dt.Xcode
➜ ~ /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' /Applications/Xcode-8.3.app/Contents/Info.plist
8.3
➜ ~ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.3.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"
Just installed Xcode 8.3 on another machine, (this time keeping 8.2.1 around) and ran these tests again after having launched Xcode 8.3.
$ mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"
/Applications/Xcode-8.2.1.app
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.2.1.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"
Most other people around me have tried this experiment and seen the Xcode 8.3 path be discovered immediately 😩 #doesntworkonmymachine
Doesn't work on my machine either.
$ mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"
(empty response)
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app
kMDItemCFBundleIdentifier = (null)
I've mostly only been using XcodeInstall to do the fetching of the dmg/xip files and not actually doing installs (so I am usually using something like xcversion install --no-install --force
), so I don't exercise this code much. This seems like a Spotlight/LS bug, though.
I suppose another approach would be if XcodeInstall instead just checked installed copies located only at /Applications
via paths and (for example) querying the CFBundleVersion
. Since XcodeInstall doesn't give an option for installing an Xcode elsewhere, it seems like it's potentially confusing that it detects installations elsewhere and changes behaviour depending on that.
I tried mdls
.
It returns different values by install methods.
returns (null)
when installed via Mac App Store. However, installed xip directlly, it returns com.apple.dt.Xcode
. 🤔
This behavior seems to be a bug. I think this issue would be fixed on next version. maybe...
We can't find Xcode by Spotlight at all.
Reindexing Spotlight worked for me. No idea why, but seems to be fixed.
I agree with @timsutton, why make this more complicated than it has to be?
I ran sudo mdutil -i on /
to reindex spotlight and that fixed it for me (after a few hours).
Fixed for me with 9.1 as well.
sudo mdutil -E /
sudo mdutil -i on /
fixed the issue for me 🙌