Friday, October 30, 2009

Section 22.5.  Project Indexing










22.5. Project Indexing


As mentioned in Section 18.1.2, Xcode will devote a background thread to identifying and indexing all the symbols in your project and the frameworks it uses. On recent machines, with a moderately sized project and a reasonably paced typist, you will see no effect, other than having an index, from the indexing thread. In some cases, however, indexing may slow your machine down.


The drastic thing you can do about this is to turn indexing off. In the Code Sense pane of the Preferences window, clear the checkbox labeled Indexing: Enable for all projects. No indexing threads will then be started; nor will you be able to use the Class Browser, the Class Model, the Project Symbols smart group, Code Sense, or command-double-clicking to find symbol definitions.


The less drastic step is to reduce the amount of indexing that has to be done. In all but the very largest project, the lion's share of indexing is done in frameworks, and it makes sense to do that part of the indexing once, in advance, and have individual projects use these master indexes as bases for project indexes. The facility is formally known as index templates, and you have to build and enable them to make use of them.


You will find the necessary makings in /Developer/Extras/Xcode Index Templates/. There is a way to build and enable templates piecemeal and to control where they are stored, but for most purposes, it's good enough to build them all, store them in the /Library domain, and enable Xcode's use of them. Do this in the Terminal application by focusing on the templates directory and executing the command install_templates found there:


   $ cd "/Developer/Extras/Xcode Index Templates"
$ sudo ./install_templates
Password:
$


More information about index templates, including details on manual installation, can be found in the read-me file in the Xcode Index Templates directory.


It sometimes happens that features that depend on indexing stop working or work unreliably. Code Sense, for instance, might not be delivering all the completions you think it ought to, given the context. It is possible that the project index has been corrupted. If you think that this may have happened, select Edit Project Settings in the Project menu (or double-click the Project icon at the top of the Groups & Files list), and click Rebuild Code Sense Index at the bottom of the Info window that results.


If a problem persists and you are using index templates, see whether turning index templates off and rebuilding the project index cures the problem. If so, rebuild the index templates before using them again.












No comments: