Xcode Open Quickly – Efficiently Navigating Xcode

This post is a simple but powerful tip. If you’re not using Xcode’s Open Quickly, today’s post should help you dramatically improve your efficiency when navigating code. When I showed Open Quickly to a colleague for the first time, their response was “that’s a game changer!”

Accessing Open Quickly

There are two ways to access Open Quickly:

  1. Menu: File > Open Quickly
  2. Keyboard shortcut: Command + Shift + O (⇧⌘O)
Xcode Open Quickly

Great. What does it do?

Once you have the Open Quickly dialog open you may use it to search and open files or symbols. A symbol can include a variable, enum, type, constant, method, or class. The search uses a fuzzy match. This means you can search for files and symbols even if you only remember a few of its characters. For example, if I have a function called  updateBottomLayoutConstraintWithNotification: I could just enter ‘upblaconnotif’:

Xcode Open Quickly Fuzzy

Open Quickly provides a list of matching files and symbols. For each match, you’re given the matches type (in the example M for Method). The full filename or symbol is also displayed along with its location in your workspace. Remember that the search is fuzzy, so you can add as many or as little characters as you like. Finally, the search is case insensitive.

OK, how do I Open a File?

You can use the arrow keys to navigate through the list of matches, then kit the enter key. Double-clicking the desired match will also open it. Holding the Option key when opening the match will open it in the Assistant Editor. Holding Option-Shift will allow you to choose where the match is opened.

Searching for a Specific File Type

To search for a specific file type, add a dot to your search and the file extension you want:

Xcode Open Quickly File Extension

Search for a Line Number

A line number can be specified too. This can be particularly useful when you want to direct a colleague to the exact location of some code. It’s also great for finding the exact location of a crash from a crash report:

Xcode Open Quickly Line Number

Type in your search text and add a colon with the line number your’e interested in.

Apple’s documentation on Open Quickly can be found here.

Random Crashes with Xcode 4, LLVM 2.0, and armv6

After recently deploying a simple update to Boxing Timer, I started to get support requests about the app crashing. I couldn’t understand what would cause the crashes as the update was simply adding French localisation. Some quick smoke testing revealed no issues on an iPhone 4 or iPad. However, reverting back to an iPhone 3G or iPod touch G2, I was able to reproduce the crash. What was particularly strange was that the crash could only be reproduced by exercising a very specific code path. In general though, the app seemed to work fine. However, when the app did crash the logs looked something like this:

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000002
Crashed Thread: 0

Thread 0 Crashed:
0 ??? 0x00000002 0 + 2

Thread 1:
0 libSystem.B.dylib 0x000014b8 mach_msg_trap + 20
1 libSystem.B.dylib 0x00004094 mach_msg + 60
2 CoreFoundation 0x00057002 CFRunLoopRunSpecific + 982
3 CoreFoundation 0x00056c18 CFRunLoopRunInMode + 44
4 WebCore 0x000846f0 RunWebThread(void*) + 412
5 libSystem.B.dylib 0x0002b7b0 _pthread_body + 20

Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x380ab7fc r3: 0x00138a50
r4: 0x00138a50 r5: 0x00019dd0 r6: 0x00138a50 r7: 0x3817b1b4
r8: 0x00170f80 r9: 0x001fc098 r10: 0x00000004 r11: 0x38179ff4
ip: 0x3810a810 sp: 0x2ffff300 lr: 0x30b336c4 pc: 0x00000002

As it turned out the LLVM 2.0 compiler that shipped with Xcode 4.0 and 4.0.1 was responsible for these crashes. Fortunately Xcode 4.0.2 has fixed this issue. I was able to rebuild my app and get an expedited review, which equals happy customers again!

In a nutshell if you’ve been using Xcode 4.0 or 4.0.1 to build your apps with LLVM 2.0, they will most likely experience crashes on armv6 devices. So make sure you’ve upgraded to Xcode 4.0.2.