Aug 30, 2010 / iphone
iPhone Tip: Achieving Dev Speed in xCode

When using development tools, I personally prefer it if my hands don't have to spend time moving between keyboard and mouse. Keyboard shortcuts rule the roost.

I've only been developing in xCode for a few weeks, but I've managed to get a workflow that comes closer to the speeds I'm used to with Visual Studio + Resharper, or TextMate.

Learning a 5-10 keyboard shortcuts greatly helps your speed of development I find, here's the ones I use, in rough order of frequency used. Start learning the top ones as they're the most useful, and work down.

Key Legend

Apple Key = Apple (Command) Key

Shift Key = Shift Key

Ctrl Key = Ctrl Key

Option Key - Option Key

Symbols come from the handy Key Me site.

Oh, First Setup xCode!

I find it better with less visual noise when coding, so I like to work in a single code window, rather than having tons of code windows open. The default xCode pane as 3 splits - left, top and bottom. I just get rid of the top one to make more space.

To toggle the top pane:

Apple Key+Shift Key+E

Navigating Between Files Quickly

Open By Name

Rather than using the tree view on the left hand side, I tend to use the quick Open Quickly feature. This is invoked using Apple Key+Shift Key+D, and you can then just type in the start of the file your looking for and it will suggest the right ones. Use the up and down arrows, then enter to select.

Recently Opened

Ctrl Key + 1 will get you a quick list of recently opened files. Use up-arrow and down-arrow key (or page up/down) to move around in the list. Enter to select the file you want.

Header/Footer

You can switch between .h and .m file using Apple Key+Option Key-arrowup

Moving Around Within File

History Back and Forward

Apple Key+Option Key+left or Apple Key+Option Key+right

Jump to Method

Ctrl Key + 2 will get you a quick list of methods in the current file. Use up-arrow and down-arrow key (or page up/down) to move around in the list. Enter to select the file you want.

Build and Run

If I just want to check things are ok, I use Apple Key+B. That does a build and reports errors.

If I want to run the code on the Simulator, I use Apple Key+R.

I usually want to see the console output, so I do an Apple Key+Shift Key+R to see that. I also clear the console quite often using Apple Key+Shift Key+Ctrl Key+R.

If you get errors or warnings at build time, you can make them visible in the editor using Apple Key+Shift Key+H (toggles errors and warnings on off).

Help

Shift Key+Ctrl Key+? will bring up some quick help for the item under the cursor. Use that quite a lot when I don't know what method signature parts are, etc.

Editing

Commenting selection is done using Apple Key+/. Quite handy for bulk operations.

Refactoring

xCode 3 doesn't have great refactoring, but I use Extract Method and Rename a LOT! Apple Key+Shift Key+J gets you the refactoring window, then I usually have to grab the mouse to select and type from there.

Links

There's a handy pdf showing a small summary of these shortcuts and more.

This PDF is even more in depth.

Note: I created a little site called Key Me to make it easy to embed key images into this file. View source of this page to see how you use it.


You may also like...