如何在 Xcode 4中禁用索引?

不久前,我将 Xcode 更新到了版本4。这个新版本花了很多时间为项目建立索引(它非常大)。这就是为什么我想禁用索引。通过 Xcode 帮助和互联网搜索没有结果。

29501 次浏览

It's not possible to disable indexing in Xcode 4. Many of the IDE's features are built on top of the index it maintains.

Reducing the priority of the XCode process helps:

renice 10 -p PID

You can get the PID from the Activity Monitor or top/ps commands.

Open a terminal window and paste this command:

defaults write com.apple.dt.XCode IDEIndexDisable 1

You'll lose some features (autocomplete, jump to definition, some of the assistants won't work right). But you'll gain back ram and cpu.

For my project Xcode went from using 2 Gigs to a few hundred MB. (which I sorely needed to compile with ;))

This problem has been noticed on this newsgroup:

The crux of it seems to be that XCode4 uses crazy amounts of ram during indexing - like, 5gb or so(!), and thus if you're on a machine with something like 12gb, there's no problem, but if you're on a laptop with only 2gb or so, you'll have some pretty severe paging going on.

I'm guessing apple's internal engineers were all rocking maxed-out mac pros or something.

I ran into either the same problem or something similar. My project includes heavily templated C++. Including those headers in the PCH file solved the problem for me.

Slow indexing is not a given. And more memory isn't necessarily better.

I have a medium sized project for work ~ 500 source files. After deleting the derived data, it takes 18 minutes to finish reindexing this project. That's with no other apps open and not doing anything else with the computer. This is on a fairly recent Macbook Pro with 8G of memory and an i7. Horrible, right?

My home machine is a recent Mac Mini with 4G of memory and an i5. On that machine the exact same project takes 40 seconds to completely index.

I don't yet know what the difference is, but I'm working on it.

My new retina Macbook pro running XCode 4 was extremely slow doing indexing (and everything else). My Mac mini at home was very fast working on the same project!? Turns out it was my anti-virus software - doing a scan of every file read or written on the MacBook. Turning that off sped everything up by a ton.