Xcode Efficiency Tips: Keyboard Shortcuts

xcodegraniteincon

Although other IDEs exist, Apple’s Xcode remains the most popular choice for development of iOS applications. At Atomic, we highly value efficiency, so it’s important for a developer working in Xcode to familiarize themselves with at least some of the most useful keyboard shortcuts. To that end, this blog post will cover some of the keyboard shortcuts and resources I find myself using the most.

Exhaustive Shortcut Lists

Before mentioning specific shortcuts, here’s a link to the shortcut documentation from Apple: command shortcuts . Many developers have also created useful cheat sheets for quick reference.

Big lists are great for reference, but I find it is easier to learn a new IDE in small bits, starting with what seems to be the most useful bits first (the low hanging fruit).

Finally, here are the Mac modifier keyboard symbols and what they represent (these are frustratingly non-obvious for a newcomer to Mac- for instance, why don’t the control or alt/option keys on my macbook pro keyboard also have the symbols?):

⌘ = Command
⇧ = Shift
⌥ = Option/Alt
⌃ = Control
⇠⇢ = Left/Right Arrow Keys
⇡⇣ = Up/Down Arrow Keys

Getting around Xcode’s Workspace Windows

Xcode breaks up its main workspace window into several sub-areas. When describing keyboard shortcuts, it is informative to keep these areas in mind:

  • The Editor – where most coding work is done.
  • The Navigator – where a developer can navigate through tests, project files, compiler errors, breakpoints, etc.
  • The Debug Area – used during debugging.
  • The Utility Area – quick help, file and data descriptions, etc.

workspace

Because of all the sub-areas in the workspace, screen space can get used up very quickly. That makes it important to be able to hide areas you don’t need when you aren’t using them. The utility area is a good example: when working on a storyboard or nib, I use the utility are a lot. When coding, I only find myself looking at it for quick help, so I will often hide it. Similarly, the debug area doesn’t serve a purpose when not debugging or examining output. Apple has provided shortcuts for showing and hiding all of these areas, and I found a great blog post by Robert Saunders with a helpful map (I have highlighted the shortcuts for showing/hiding areas in red):

xcodeShortcuts

Navigating in the Editor

The single most useful feature for navigating code is ⇧ + ⌘ + O, which Apple calls “Open Quickly…”, but is actually an awesome, super-fast fuzzy search for file names. As you type, the file list is quickly populated, and you can use the arrow keys to select the file to open:

ShiftCmdO

“Open Quickly…” is essential on larger projects where searching through the project navigator is not an option (if you want to remain sane).

My other most-used hotkeys in the Editor are:

⌃ + ⌘ + ⇡ OR ⇣
⌘ + click on a variable/type
⌃ + ⌘ + ⇠ OR ⇢
⌃ + ⌘ + E
⌘ + T
⌘ + W
⇧ + ⌘ + [ OR ]
Switch between .m and .h files
Go to definition
Go forward / Go back
Edit all in scope
Open a new tab
Close the current tab
Go forward / Go back in tabs

Building, Running, Testing

Xcode puts a big “play” button in the upper left corner of the workspace and many build/clean/run options in the Product menu, but using keyboard shortcuts for these common tasks is a big time saver:

⌘ + B
⇧ + ⌘ + K
⌘ + R
⌘ + U
⇧ + ⌘ + ⌥ + G
Build
Clean
Run (build if necessary)
Run tests (build if necessary)
Re-run the last run tests

Debugging

Lastly, there are a few shortcuts I find myself using over and over again while debugging:

F6
F7
⌘ + \
⌘ + Y
⌃ + ⌘ + Y
Step over
Step into
Add/remove breakpoint
Disable/enable all breakpoints
Pause/Play the debugger

Learning and using Xcode keyboard shortcuts enough to build up muscle memory has really improved my coding speed and efficiency. Whenever I talk hotkeys with other iOS developers (exciting!) we always seem to teach each other new keyboard shortcuts — so I’d love to hear from other developers out there which they find most useful; I’m sure I’ve missed some!

 

 
Conversation
  • manu says:

    Thanks, this is something I’m going to use, definitively.

    • John Fisher John Fisher says:

      Glad to hear it, manu. xCode can be rough at times, but knowing the keyboard shortcuts helps a lot.

  • nave says:

    this is cool codes – thank u

  • Viswanath Reddy says:

    Nice Tutorial. It’s very useful to me .

  • Jayapal Natarajan says:

    Nice effort.. Much needed for the beginners like me. thanks a lot.

  • hanguytv says:

    Very usefull. Thanks!

  • Abdul Rauf says:

    very help full shortcuts, Thanks :)

  • Aditya says:

    This is Awesome!! Given so much Confidence. Appreciate your effort.

  • I am John, how are you everybody? This article posted at this website is really good.

  • Anitha says:

    Very Helpful
    Thank you

  • Nitin says:

    Very useful.
    + one more
    ⌘ + L Go to Line

  • JRB-BLDR says:

    As a new iOS XCode developer struggling to use web references to learn what/where to go to accomplish a task.
    In doing so I often see references to things like “Navigate to Settings”, but have no idea how to do that in the GUI.
    In the Navigate window I cannot find “Settings” on any dropdown, not in the icon ‘hints’ nor anywhere else.
    Might you shed some light on this as well?
    Thanks

  • Richard says:

    Thanks. Simple but very useful tips

  • Anil U says:

    Hi John,

    Good articles, It is very helpful to do code using xCode so efficient and fast.

    Thanks for Sharing.
    I am looking for same kind articles.

    Thanks,
    Anil

  • Rhee says:

    hi thank you!

  • xpucsc says:

    thank you so much!

  • Magnus says:

    Hi John, nice article!

    Is there a way to go to previous cursor position as opposed to previous file (⌃ + ⌘ + ⇠ OR ⇢) ?

    I do that all the time in Android Studio and would like the same in Xcode.

    Cheers

  • Viral Thakkar says:

    Nice articles, thanks

  • Comments are closed.