Quickly Find Project Files in Xcode

November 6th, 2005

I like the Search-Fieldy kind of thing in Xcode. If you select the top-level project item in the “Groups and Files”, and then enter something in the search box, it makes it really easy to pinpoint a particular file that is contained by your project.

Apple even gave this search box thingy a keyboard shortcut, and include a menu item in the View menu for accessing it: “Detail”. I don’t really get the name of that menu, but needless to say it will switch you over to the search box thingy whenever you invoke it.

Problem is, I am almost 100% likely to want to search my entire project when I switch to it, but Xcode doesn’t do this for me. I hit shortcut and then I inevitably have to go click the project icon in the outline view before switching back to the search box to enter text.

Using GUI Scripting, I was able to solve this dilemma by writing a small script that simply clicks the project item for me before switching to the search field. The script asks the “Groups and Files” outline view for the “first top level item whose name is the same as the name of the project.” I’m pretty sure this will always be the desired row of the column, even if you’ve done some funky reordering of items.

Click here to download: Find Project File

I used FastScripts to assign an Xcode-specific shortcut override. Now when I hit the Cmd-Opt-F shortcut for “Detail” it behaves as usual, but clicks the project icon for me on the way.

Update: Xcode’s “whose clause resolution” started flaking out and giving me false hits, so I decided to just rely on the Project item being the first item in the Files and Groups list. This has the added benefit of making the script a lot faster, but it means it won’t work if your Files and Groups list is customized with the project not at the top.

No Responses to “Quickly Find Project Files in Xcode”

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.