41

I got my Xcode into a non-functional state when I can no longer start a search: once I press ⌘+F, Xcode hangs with a spinning pinwheel, and stops responding. Once this happens, my only option is to force quit and restart.

I tried looking for the saved settings in the workspace and project directories, but the recent search options that I am looking to delete appear to be stored elsewhere. I know that I could clear recent searches through the UI, but that would require bringing up the search dialog, which hangs Xcode.

I would like to reset Xcode to its original state. How do I do it without reinstalling Xcode?

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Having same issue, any resolution to this? It's a very hard problem to search for. "xcode search crash" yields incorrect results for example – 1dayitwillmake Dec 28 '14 at 18:26

2 Answers2

69

This is the officially recommended way to delta Xcode 5's preferences, type in Terminal.app:

defaults delete com.apple.dt.Xcode

That should restore Xcode to the state of its first launch.

(for older versions of Xcode the command was defaults delete com.apple.Xcode, i.e. without the dt in the middle).

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
Nils Hott
  • 1,650
  • 15
  • 16
  • 2
    Although this did not fix my Command+F problem, it did clear out the old settings. I updated your answer to work with the current version of Xcode. Thank you very much! – Sergey Kalinichenko Jan 15 '14 at 19:47
  • 1
    it resolved my problem of not indexing files.. i tried with several steps before. Thanks for the post. – Tarun Mar 04 '14 at 10:30
  • 1
    This fixed the problem with my swift files not showing up when I created a new file – UKDataGeek Jan 04 '15 at 10:52
  • 1
    I enter the code but nothing happens !! `xcode 7.1.1` – iOS.Lover Nov 21 '15 at 10:24
  • 1
    Thank u, this fixed my problem where Xcode was crashing on this error `UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[IDE SourceKit Workspace allSymbolsMatchingNames:kind:]:` – Husam Apr 27 '19 at 08:40
  • 1
    Fixed issue where couldn't make a NEW FILE – rezwits Dec 24 '20 at 05:23
21

Reset all XCode settings from command line by running following commands then restart XCode:

defaults delete com.apple.dt.Xcode
rm -rf $HOME/Library/Application\ Support/Developer/Shared/Xcode
rm -rf $HOME/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
rm -rf $HOME/Library/Preferences/com.apple.dt.Xcode.*
FuegoFro
  • 3,867
  • 2
  • 18
  • 14
Aqib Mumtaz
  • 4,936
  • 1
  • 36
  • 33