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:
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
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.
⇧⌘ o Open quickly
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.
⌘ L Go to line
and enter the line number.
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
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
⌥⌘[ Move line up
⌥⌘] Move line down
⌃I Re-indent code
If you need to comment things out just press:
⌘/ Comment/uncomment line or selection
⌘↩ Standard editor
⌥⌘↩ Assistant editor
⌥⇧⌘↩ Version editor
⌥⌘, Open in assistant editor
⌘\ 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
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.
You can also filter results so you can see only the failing tests:
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 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
⇧⌘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.
You have covered the required shortcuts. Thanks for the post…
Thank you, very much.