`xcodes uninstall` doesn't unregister Xcode from LaunchServices
When xcodes uninstall is used to delete a Xcode version, this Xcode version isn't unregistered from LaunchServices, so this old version remains on the LaunchServices database indefinitely.
- This can be checked with this command:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep <XCODE_FOLDER> - More info about the unregistering apps from LaunchServices here.
Possible solutions:
- Find a replacement for
removeItem(atPath:)that also updates the LaunchServices database. - Add a new phase to
xcodes uninstallto unregister the uninstalled Xcode version (/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f -u <XCODE_PATH>, although this command doesn't seem to work for the apps inside Xcode).
@juanjonol Do you know if this is still an issue? I recently used xcodes uninstall and ran the following but didn't get any output:
lsregister -dump | grep ~/Library/Developer/Xcode/DerivedData
@A00736470 to test this issue you need to use the directory where Xcode is installed, not Derived Data. So if Xcode is installed on /Applications, the command would be lsregister -dump | grep /Applications and see if there're old Xcode versions there. DerivedData has a similar problem, as reported on the blog post I linked on the original post, but it's unrelated to xcodes.
That said, I'm not sure if this is still an issue: I don't think xcodes has done anything about this, but I've used a custom script to uninstall and unregister Xcode versions for years, so I cannot test it on my machines, and it's plausible that modern macOS versions are more aggressive about unregistering old apps.