5

Since the App Store seemed stuck with updating Xcode to 7.3, I have decided to delete it and reinstall. However, after moving Xcode to the Trash, it refused to be cleared and instead be stuck on the "Preparing to empty the trash..." window. So, I've decided to force empty the trash in Terminal by rm -rf ~/.Trash/*, only to get an endless loop of error message saying this:

rm: /Users/jordanchanph/.Trash/Xcode.app/Contents/.../IOCatalogue/reset.xml: Permission denied

How can I empty the trash?

4 Answers 4

6
sudo rm -rf ~/.Trash/*

is your friend.

I would think cause of the errors are permissions, perhaps Xcode sets files with permissions exclusive to root (superuser).

What sudo does is run the following command (rm -rf ~/.Trash/*) with root privileges - think of it as "when in doubt with permission denied, sudo". Of course, the permission denied error is not to be ignored as it could be a sign of permissions errors. But, if you know what you are doing, sudo solves your problems. (this sums it up nicely)

1
  • 1
    And what if it does not work and hangs instead ?
    – Renetik
    Jul 23, 2018 at 5:15
2

Make sure of the following:

  • No Apple devices (iOS, iPad, ...) are connected to your computer (MacOS Catalina or later)
  • iTunes is not open or running (MacOS High Sierra or earlier)

They hog some resources XCode uses and therefore prevent it from being deleted.

1
  • 2
    This was a key point for me. I had tried all of the reboots and "sudo removes" and had all devices unplugged from my machine... but I still couldn't delete xcode. After seeing this, I realized that my phone was connecting via wifi, so I turned off wifi and bluetooth, and the regular "empty trash can" method worked. Dec 30, 2019 at 19:59
0

I ran (rm -rf ~/.Trash/*) on my MacBook Pro (mid 2012) running 10.13.6 and it hung.
I opened up Trash, right-clicked on XCode and opened up Package Contents, then clicked "delete immediately" while the 'rm' command was still running. I saw "deleting 0 items". I terminated the 'rm' command and 'x'd out of the "deleting 0 items" window.

Now comes the strange part. I clicked on the name of one of the components, intending to edit it (that has worked for me in the past). Instead of taking my edit, it the editing highlight disappeared, and then the component itself went away.
I did this successively for the other components, and after the last one, XCode itself vanished from the Trash folder.

I don't have an explanation, but I suppose the point is that this technique worked.

0

I found that going into the Package Contents and Moving the contents folder to the trash, then opening that up, and deleting each individual folder by itself works. There are some files that won't delete for some reason. If it doesn't delete, then open that folder up and delete those files individually. Etc. etc. It worked and only took a few minutes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .