163

I have an issue that I can only assume is with Xcode, where my apps take forever to run and crash the phone/restart about 75% of the time. I tried using older versions of the code that I'd saved instead, but they had the same effect, which they didn't use to have about a month ago.

I've looked up every single possible way to solve this issue for the past few weeks have haven't found anything, so I want to completely uninstall Xcode and clear all settings; but I can't find a way to do this. I can uninstall it, but when I reinstall it, it still has all of my old settings and lists of projects etc. How can I completely uninstall it?

Rashwan L
  • 38,237
  • 7
  • 103
  • 107
robestrong
  • 1,723
  • 2
  • 12
  • 8
  • I did end up solving it, and it didn't have to do with Xcode specifically, but required the device I was using be cleared. – robestrong Sep 21 '15 at 18:11
  • 1
    Found that if you have an emoji in the pathname of where Xcode is stored, the Xcode simulators after iOS 11 don't run correctly. I put my Xcode into a folder with a bunch of related aliases. The folder was named "" so it's path was /Applications/Development//Xcode.app. This caused only the new simulators to hang. The old ones ran fine as before. – Cerniuk Jan 11 '19 at 15:20

7 Answers7

233

For complete removal old Xcode 7 you should remove

  1. /Applications/Xcode.app
  2. /Library/Preferences/com.apple.dt.Xcode.plist
  3. ~/Library/Preferences/com.apple.dt.Xcode.plist
  4. ~/Library/Caches/com.apple.dt.Xcode
  5. ~/Library/Application Support/Xcode
  6. ~/Library/Developer/Xcode
  7. ~/Library/Developer/CoreSimulator
Brian McCutchon
  • 8,354
  • 3
  • 33
  • 45
kpod13
  • 2,430
  • 1
  • 11
  • 3
  • 15
    In xcode8 timeframe, change #3 and #4 to end with `com.apple.dt.*` since Instruments and other xcode components are also writing plists – xaphod Oct 19 '16 at 14:16
  • 20
    and `~/Library/Developer/CoreSimulator`, can be cleaned as: [http://stackoverflow.com/questions/33419301/coresimulator-folder-very-big-ok-to-delete-content](http://stackoverflow.com/questions/33419301/coresimulator-folder-very-big-ok-to-delete-content) – andrewchan2022 Nov 22 '16 at 17:14
  • 12
    Something **Important**: you can delete anything under `/Library/Developer/` directory, such as `CommandLineTools` and `CoreSimulator`, EXCEPT `PrivateFrameworks` subfolder; or else your newly installed Xcode will crash until you put it back. Just be careful about the system directory. – DawnSong Sep 20 '17 at 07:13
  • @DawnSong I had accidentially deleted the files under `\Library \Developer` , I then installed commandline tools for macOS. Still my xcode keeps on crashing. My Developer folder currently has `commandlines Tools` in the directory. How should I fix this problem? – Aakash Dave Sep 28 '17 at 11:08
  • 3
    @AakashDave Copy from your friend's mac, haha. – DawnSong Oct 12 '17 at 07:26
  • @kpod13 I followed your advice, but libraries are showing red in .xcworkspace now and I get some errors. Could you please have a look at my question https://stackoverflow.com/questions/50237202 – bibscy May 08 '18 at 15:36
  • if you deleted `PrivateFrameworks` - https://stackoverflow.com/a/50176504/3446071 – Lexx918 Sep 28 '18 at 16:19
  • 1
    Following the manual steps in this guide: https://macpaw.com/how-to/uninstall-xcode-on-macos I deleted the whole `~/Library/Developer/` folder and this solved my problem, making it possible to download and install Xcode from the App Store. (This was for Xcode 9 & 10.) – Paul Masri-Stone Feb 13 '19 at 17:41
  • 6
    I had to delete this too **rm -rf ~/Library/Developer/XCTestDevices** – Lance Samaria Nov 12 '19 at 04:08
73

For a complete removal of Xcode 10 delete the following:

  1. /Applications/Xcode.app
  2. ~/Library/Caches/com.apple.dt.Xcode
  3. ~/Library/Developer
  4. ~/Library/MobileDevice
  5. ~/Library/Preferences/com.apple.dt.Xcode.plist
  6. /Library/Preferences/com.apple.dt.Xcode.plist
  7. /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.bom
  8. /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.plist
  9. /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.bom
  10. /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.plist
  11. /private/var/db/receipts/com.apple.pkg.Xcode.bom

But instead of 11, open up /private/var/in the Finder and search for "Xcode" to see all the 'dna' left behind... and selectively clean that out too. I would post the pathnames but they will include randomized folder names which will not be the same from my Mac to yours.

but if you don't want to lose all of your customizations, consider saving these files or folders before deleting anything:

  1. ~/Library/Developer/Xcode/UserData/CodeSnippets
  2. ~/Library/Developer/Xcode/UserData/FontAndColorThemes
  3. ~/Library/Developer/Xcode/UserData/KeyBindings
  4. ~/Library/Developer/Xcode/Templates
  5. ~/Library/Preferences/com.apple.dt.Xcode.plist
  6. ~/Library/MobileDevice/Provisioning Profiles
Cerniuk
  • 14,220
  • 2
  • 29
  • 27
44
  1. Open Storage Management

    • Go to  > About This Mac > Window > Storage Management
    • Or, hit ⌘ + Space to open Spotlight and search for Storage Management.
  2. Select Applications on left pane.

  3. Right click on Xcode on the right pane and select delete.

This will remove XCode from the installed applications list of your Mac's App Store.

Update: This worked for me on macOS Sierra 10.12.1.

Joyce Babu
  • 19,602
  • 13
  • 62
  • 97
  • 1
    Might need to add some info around what versions of OS X this is valid for, don't see it as of 10.11.6 – Matt Sanders Dec 27 '16 at 19:17
  • 1
    I don't remember whether it moved Xcode.app to Trash. But the above process removed XCode from AppStore. – Joyce Babu Sep 20 '17 at 11:18
  • 3
    "This will remove XCode from AppStore." Really? – Alexander Volkov Dec 05 '17 at 05:42
  • 2
    @AlexanderVolkov From App Store *on your Mac*. My installation somehow got corrupted, and I was unable to uninstall or re-install the software. Even installation from the DMG file kept failing, because it is marked as installed in App Store. – Joyce Babu Dec 05 '17 at 10:59
  • 4
    On `10.13.3` the delete option is there but it does not do anything – tread Sep 12 '19 at 05:40
  • This will not delete all meta files like here https://stackoverflow.com/a/33812614/1179925 – mrgloom Feb 18 '20 at 12:27
23

Before taking such drastic measures, quit Xcode and follow all the instructions here for cleaning out the caches:

How to Empty Caches and Clean All Targets Xcode 4

If that doesn't help, and you decide you really need a clean installation of Xcode, then, in addition to all of the stuff in that answer, trash the Xcode app itself, plus trash your ~/Library/Developer folder and your ~/Library/Preferences/com.apple.dt.Xcode.plist file. I think that should just about do it.

Community
  • 1
  • 1
matt
  • 515,959
  • 87
  • 875
  • 1,141
11

FOR UNINSTALLING AND THEN BEING ABLE TO REINSTALL XCODE 9 CORRECTLY

I followed the topmost answer for deleting Xcode 7 and found a major error, deleting ~/Library/Developer will delete an important folder called PrivateFrameworks, which will actually crash Xcode everytime you reinstall and force you to have to get your friends to send you the PrivateFrameworks folder again, a complete waste of time seeing if you needed to uninstall and reinstall Xcode urgently for immediate work purposes.

I have tried editing the topmost answer but see no changes so below is the modified steps you should take for Xcode 9:

Delete

/Applications/Xcode.app

~/Library/Preferences/com.apple.dt.* (Generally anything with com.apple.dt. as prefix is removable in the Preferences folder)

~/Library/Caches/com.apple.dt.Xcode

~/Library/Application Support/Xcode

Everything in /Library/Developer directory except for /Library/Developer/PrivateFrameworks

mding5692
  • 806
  • 1
  • 10
  • 34
  • 6
    I think you mean remove `/Library/Developer` except for `/Library/Developer/PrivateFrameworks`, PrivateFrameworks doesn't appear to exist for me in the home folder version of `Library/Developer` also note, that `/Users/USERNAME/Library/Developer/Xcode/Archives` contains the xcode archives (as in archives of what you have built) so you might want to save that – mgrandi Mar 16 '18 at 20:46
  • 1
    Yeah for some PrivateFrameworks is there and if delete will cause crash if you need to reinstall Xcode afterwards, guess my instructions can be misread but I meant delete everything except for PrivateFrameworks – mding5692 Mar 17 '18 at 08:32
  • 2
    mgrandi is correct `/Library/Developer` is different than `~/Library/Developer`. The former contains `PrivateFrameworks` folder not the latter. – Orkhan Alikhanov Jan 08 '20 at 09:18
6

This answer should be more of a comment against Dawn Song's comment earlier, but since I don't have enough reputation, I'm going to write it as an answer.

According to the forum page

https://forums.developer.apple.com/thread/11313

"In general, you should never just delete the CoreSimulator/Devices directory yourself. If you really absolutely must, you need to make sure that the service is not runnign while you do that. eg:"

# Quit Xcode.app, Simulator.app, etc
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator

I definitely ran into this issue after deleting and reinstalling Xcode.

You might encounter a problem trying to connect the build to a simulator device. The thread also answers what to do in that case,

gem install snapshot
fastlane snapshot reset_simulators
ykonda
  • 499
  • 6
  • 15
-11

Run this to find all instances of Xcode in your filesystem:

for i in find / -name Xcode -print; do echo $i; done

  • 4
    This may show unexpected things if there are any file name clashed e.g like I have several folders called `Xcode Projects` and this would print them out. – Jesse Onolemen Aug 19 '17 at 08:33