xcodes icon indicating copy to clipboard operation
xcodes copied to clipboard

`xcodes uninstall` doesn't unregister Xcode from LaunchServices

Open juanjonol opened this issue 3 years ago • 2 comments

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 uninstall to 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 avatar Oct 21 '22 13:10 juanjonol

@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 avatar Jan 15 '25 18:01 A00736470

@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.

juanjonol avatar Jan 16 '25 22:01 juanjonol