Rehat’s Hammer — maybe after this article you can lift it too! (illus. by Jeremy Booth)

Xcode, Supercharged

As engineers one of the most important things we can do is become accustomed to the tools we use on a daily basis, but we really shouldn’t stop there. Wherever possible, we should try to master and customise these tools to make our ultimate goals both faster and easier to achieve. The following are bite-sized tips and tricks I’ve picked up during my time spent programming in Xcode. I hope you’ll find them helpful.

  1. Ctrl + Numbers

Xcode allows you to quickly navigate all the way from project folders down to functions by combining the +[1/2/4/5/6] keys. The panels presented using this shortcut are searchable too.

2. Breakpoint Jingles

Breakpoints are awesome. They can also be supercharged. Did you know that you can execute awesome llvm commands and play jingles each time the instruction pointer hits one? Combine those with an automatic continuation for those special times when you’d like to know a function is called without having to constantly continue program execution.

Look at all those options!

3. Fuzzy Search Anything

Can’t remember where the specific thing you’re looking for exists? Xcode allows you to fuzzy-search an entire project by hitting ⌘⇧O. Key part of this functionality is that it’s fuzzy; if there are multiple search results in your search you can continue typing until there’s one desired result.

Too many options!
That’s much better!

4. Editing In Scope

Place your cursor anywhere over an instance variable/function name and hit ⌘⌃E. Notice how every instance of that word has been highlighted? Change it once and Xcode will change it everywhere in the class inside which it sits. Use this for when you need to rename an instance variable and or function name. This also works for local variables defined in function scopes for when the coding-coffee-spill isn’t as bad. Extremely handy when you don’t think twice before naming variables/functions.

5. camelCase Selection

The following works brilliantly in conjunction with the one mentioned just before; Xcode allows you to select by camelCase using the key. This becomes even more useful when you pair it with the shift and arrow key to highlight specific parts of a camelCase variable. Note that the selection keystroke clashes with one of OSX for jumping between spaces so you might have to disable that gesture from System Preferences to see this one work.

6. Easy Hopping Between Editor and Navigator

Want to hop to the file you’re currently editing in the navigator? ⌘⇧J. There it is. In all its glory. Want to hop back to the editor on the right hand side but don’t want to reach for your trackpad because that’s too slow? ⌘J. Bonus: you can also search for a specific file in the file navigator with ⌘⌥J.

7. Variable Breakpoints

Add a breakpoint on the line of an instance variable declaration and Xcode will stop the instruction pointer each time that variable is modified.

8. Quickly Jump To Definition

Have you ever clicked an Apple Framework function or property to find out more about it? Place your keyboard cursor blinking thingy anywhere over the text and hit ⌘⌃J. This also works for your own functions and variables.

9. Difference Since Last Commit

Who needs a third party git diff tool when you can view differences right inside Xcode with the comfort of your custom theme? ⌘⌃⌥

10. Quick Breakpoint Toggling

Hit the ⌘: keys to toggle breakpoints for the line on which your marker currently sits. Also use ⌘Y to toggle activation of breakpoints on a project level basis.

These keystrokes have now become a part of my everyday work and have helped speed up the the pace at which I write and refactor code. If, perchance, any of the keystrokes conflict with custom ones you have set up beforehand you’ll be happy to know that they’re all customisable. Just hit ⌘, and navigate to “Key Bindings”. Happy faster programming!