Xcode 5 – Tips and tricks

Share the joy

Xcode is the most used IDE for iOS development. Apple is doing a great job in updating and adding features to it. Knowing how to take advantage of its capabilities can help you code faster and more efficiently.

Xcode’s workspace window is split into 5 main areas: the toolbar, the navigation area, the editing area, the debug area and the utility area:

Xcode main areas
Xcode main areas

1. Navigating in Xcode

The navigation area has a toolbar as well. It has 8 tabs: project navigator, symbol navigator, find navigator, issue navigator, test navigator, debug navigator, breakpoint navigator and log navigator. You can quickly select one of them by pressing ⌘ and the index corresponding to it.

⌘1  Project Navigator                   ⌘5 Test Navigator

⌘2 Symbol Navigator                   ⌘6 Debug Navigator

⌘3 Find Navigator                        ⌘7 Breakpoint Navigator

⌘4 Issue Navigator                       ⌘8 Log Navigator

Project Navigator selected

 And if you need the extra space and want to get rid of the navigator then use ⌘0 (command zero).

At the bottom of the navigation area there are the navigation filters. These are different for each tab and are very helpful. In the project navigator tab, the filters allow you to see the recently modified or recently edited files. Recently modified lets you focus on your SCM changes.


You can also enter some text and try to filter the name of the files if you know what you’re looking for. However, better than using that filter is to use open quickly. The keyboard shortcut for that is:

⇧⌘ o   Open quickly


This is very handy and very smart. Even if you don’t remember the full name of the class or method you’re searching for it can still help you find it.


I didn’t even have to specify the full words (why write view controller when you can write just a few letters) and it still found what I was looking for. 

And if you want to open the file and go to line 246 because you know that’s where that method is then you can just add :246 in the open quickly window and Xcode will do that for you. And if you want to skip to another line then just press


⌘ L   Go to line

and enter the line number.

GoToLine Another very useful keyboard shortcut is the one that allows you to switch between the .h and .m file for a class.

⌃⌘⇡  Jump to Next counterpart

And a very similar keyboard shortcut if you want to go back to the previous file you were looking at. Or forward again:

⌃⌘⇢  Go forward

⌃⌘⇠  Go back

2. Editing

When you’re editing the code you might decide that an instance variable’s name is not as suggestive as it should be or that there is a spelling mistake in it. You want to rename all instances of that variable, but only in a certain scope.  Select one of the instances and then hit:

⌃⌘E   Edit all in scope

You’ll see that all the occurrences of that variable have boxes around it. Editing one will update all the others. This is very helpful for code refactoring and cleaning. Also very useful during refactoring is moving lines around. To do this you press:

⌥⌘[    Move line up

⌥⌘]    Move line down

The indentation will be fixed as you move lines up or down, but if you still have some code that’s not properly indented then use this shortcut:

⌃I   Re-indent code

If you need to comment things out just press:

⌘/   Comment/uncomment line or selection

Apart from the standard editor Xcode also has an assistant editor and a version editor. To switch from one to another you use the following:

⌘↩         Standard editor

⌥⌘↩      Assistant editor

⌥⇧⌘↩  Version editor

The assistant editor is excellent for auxiliary content. It tracks the contents of the main editor. If you need to see the superclass for your class at the same time as you’re editing the class just switch on the assistant editor. You can see counterparts, callers or test callers, includes and lots more. It is very powerful and I encourage you to use it. If you want to open a file in the assistant editor just hold the option key (⌥) down:

⌥⌘,   Open in assistant editor

3. Debugging

Normally we set or remove breakpoints by clicking the margins of the document. You can also do this via keyboard shortcuts:

⌘\   Add/remove breakpoint at current line

In the breakpoint navigator you can see all the existing breakpoints. To get to the navigator you press ⌘7

⌘Y   Activate or deactivate breakpoints

Very useful while debugging is the exception breakpoint. If your app is crashing just add an exception breakpoint and the program will stop at the line that’s causing the problem. You can do this by pressing the + at the bottom of the breakpoints navigator or from Xcode’s main menu by going to Debug-> Breakpoints -> Create exception breakpoint.

ExceptionBreakpoint4. Testing

To run all the tests in your project use ⌘U . Or ⌃⌘U to test without building.

The test editor is your best friend when running your tests. You get to it by pressing ⌘5 From here you can run only one test by pressing the little play button that appears next to it, a whole test suite or all your tests.

Tests You can also filter results so you can see only the failing tests:

FailingTestsFilter If you want to debug the test then you can add a test failure breakpoint from the breakpoint navigator the same way you would add an exception breakpoint.

5. Source control

⌥⌘C    Commit code

⌥⌘X     Update

⌃⌥⌘X  Update all

You can use the version navigator to check what’s changed in a file and who’s to blame.

⌥⇧⌘↩   Show version editor

6. Interface Builder

⌘=   Size to fit content

⌘_    Add horizontal guide

⌘|    Add vertical guide

7. iPhone Simulator

⌘⇠     Rotate left

⌘⇢     Rotate right

⌃⌘Z    Shake gesture

⇧⌘H   Home

⇧⌘M  Simulate memory warning

⌘T       Toggle slow animations


If you are interested in discovering more features and ways to use Xcode I strongly recommend watching these WWDC sessions:

  • Xcode Core Concepts – 401
  • From Zero to App Store in Xcode 5 – 403
  • Debugging with Xcode – 407
  • Continuous Integration with Xcode 5 – 412

These explain in a lot of details what you can do with Xcode and best ways to use it. It’s not just about keyboard shortcuts, it’s ways of working and customising Xcode’s views.

The keyboard shortcuts presented here are the ones I find most helpful. If you have others that you use a lot please leave a comment, I’m always looking for ways to improve.



Share the joy

2 thoughts on “Xcode 5 – Tips and tricks

Leave a Reply

Your email address will not be published. Required fields are marked *