33

I've been working with xCode 4.5.2, and have noticed that if you are indexing, you need to stop everything and let it do it's job, or else you'll get bogged down. It's become a bit of a problem, as the project is a large one, and indexing has been taking a long time to do, and it will do it constantly. One instance was it indexed the entire project, after I worked a little bit on the project it started to re-index almost 75% of the project. I checked with source control, and there had been no changes to the project in the amount of time I worked on it.

Is there any way to stop the indexing entirely, or reduce the amount of times it indexes? Are there any downsides of turning off indexing? I had read in previous questions where it was said it prevented auto-complete and searching through the project.

CBredlow
  • 2,790
  • 2
  • 28
  • 47

3 Answers3

71

Just run this command in the terminal to turn off Indexing:

defaults write com.apple.dt.XCode IDEIndexDisable 1

To turn it back on, run this:

defaults write com.apple.dt.XCode IDEIndexDisable 0

(Note: Apparently you need to delete this key in order for the change to take affect, however, I used simply the above command and it worked fine. So if doing the above doesn't work, try deleting the key)

EDIT

Sorry, missed part of the question. Yes, it will make it so searching does not work as fast. Perhaps auto-complete will get disabled. Indexing is what allows Xcode to quickly remember what you have done. Turning it off will make it slightly harder to work with, but it improves loading time.

Josiah
  • 4,663
  • 2
  • 31
  • 49
  • 1
    You actually have to delete the key to reenable indexing, see http://stackoverflow.com/questions/7328041/how-to-enable-indexing-in-xcode-4 – Stephan Tolksdorf May 09 '13 at 13:09
  • @StephanTolksdorf, Hmm, I used the above command and it reenabled just fine. But I updated my answer just in case. Thanks! – Josiah May 11 '13 at 03:02
  • 1
    Neither does it work in XCode6. Turned it of and when starting XCode I immediately see "Indexing" >:-( – qwerty_so Mar 10 '15 at 16:31
  • 1
    XCode 6.x appears to override the value shortly after start up. e.g.: `$ defaults read com.apple.dt.XCode IDEIndexDisable` outputs `1`, then shortly after XCode starts up it outputs `The domain/default pair of (com.apple.dt.XCode, IDEIndexEnable) does not exist` – Ivan Apr 25 '15 at 17:12
  • 5
    It worked for me: I just had to write the key enclosed with quotes: `defaults write com.apple.dt.XCode "IDEIndexDisable" 1` (source: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/defaults.1.html) – Ignorant Jul 17 '17 at 08:56
  • XCode's indexing time (especially when using cocoapods/carthage libraries) is absolutely unacceptable!!! – Chris Allinson Mar 08 '18 at 21:32
14

Whatever is your reason to want this (mine is "An internal error occurred. Editing functionality may be limited") for Xcode 10.1:

defaults write com.apple.dt.Xcode IDEIndexDisable -bool true

Close Xcode, run this, open Xcode.

Dark
  • 864
  • 9
  • 17
4

If you are working on a large project and generate the xcodeproj with cmake, you will get into problems when you add large binaries into it. If cmake doesn't recognize the extension it tags them as 'sourcecode' by default!

... and those binaries will then be indexed by xcode, meaning your machine is constantly indexing ( and start from scratch each time you regenerate the workspace ). Also find-in-files won't work (it just hangs).

One easy solution is to tag your binaries and tell xcode to ignore them, e.g. like this ( cmake 3.2 and higher, otherwise XCODE_EXPLICIT_FILE_TYPE isn't supported ) :

# fill cmake-variable with some files
file(GLOB MYGAME_BINARIES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "binaries/*")
# tag them as "not-sourcecode" ( maybe there is sth better than 'compiled', but it worked for my purpose)
set_source_files_properties( ${MYGAME_BINARIES} PROPERTIES XCODE_EXPLICIT_FILE_TYPE "compiled" )
kalmiya
  • 2,988
  • 30
  • 38