Top Xcode Shortcuts to Boost Your Productivity

Top Xcode Shortcuts to Boost Your Productivity
13 Xcode Shortcuts to Boost Your Productivity.Developers often spend most of their working hours on an IDE. If you’re an iOS, macOS, tvOS or watchOS developer, you’d probably be closer to your Xcode IDE than anything else at work.

Developers often spend most of their working hours on an IDE. If you’re an iOS, macOS, tvOS or watchOS developer, you’d probably be closer to your Xcode IDE than anything else at work.

I’ve often heard developers giving excuses to for not learning Xcode shortcuts when they’re starting out. In their defense, they have a valid argument:

If you don’t remember shortcuts, using a mouse at least helps you get work done quickly. Moreover, learning shortcuts feels like an additional learning curve especially when you’re getting started.

To shed some light on the impact keyboard shortcuts can have on a developer’s productivity, I’d share the findings of a study with them:

If your job requires you to be working with an IDE for eight hours a day, then using keyboard shortcuts can save you eight working days every year.

Eight days is a lot of time. By dedicating just a few hours a day, you can become proficient at using keyboard shortcuts in Xcode and save that extra week. Being productive with shortcuts would let you focus on bigger tasks at hand and speed up your development and workflow.

In the next few sections, we’ll walk through lots of Xcode keyboard shortcuts that I found useful. I hope they help you improve your efficiency as a developer too.

This is image title

Basic Shortcuts

Here’s a list of the most common shortcuts used in Xcode:

  • Build: ⌘ + B
  • Run: ⌘ + R
  • Test: ⌘ + U
  • Stop: ⌘ + .
  • Clean: ⌘ + ⇧ + K
  • Clean the build folder: ⌘ + ⇧ + ⌥ + K
  • Open quickly: ⇧ + ⌘ + O
  • Code completion: ⌃ + Space

Assistant Editors Shortcuts

Xcode 11 brought a lot of changes to their assistant editors. Now, you can add as many editors as you want, toggle focus mode on the current editor, or focuses on the current editor whilst hiding others. Additionally, a new button has been introduced that lets you set the position of the secondary editor relative to the current one.

Adding a secondary editor

The following shortcut lets you add secondary editor(s). The new editors aren’t reflected on your screen if you’re in focus mode.

Shortcut: ⌃ + ⌘ + T (Control + Command + T)

By hovering over the “Add New Editor” Button and holding the Option Key, we can toggle the position of the new editor to the right or bottom.

Focusing current editor

To hide all but the current editor, use the following set of keys:

Shortcut: ⇧ + ⌃ + ⌘ + ↩ (Shift + Control + Command + Enter)

This is image title

Opening a file manually in assistant editor

One big change in the Xcode 11 Assistant Editor is that there is no manual option. In order to open a destination file in the secondary editor, do a Shift + Command + O todo a quick open, and press the option key while selecting the file, as shown:

Shortcut: ⇧ + ⌘ + O followed by ⌥

This is image title

Navigation across editors

When working with multiple assistant editors and you need to switch between them, using the trackpad breaks the flow. Here are the shortcuts that let you deal with navigation across multiple editors:

Focus Current Editor: ⌘ + J (Command + J)

Once the editor gets highlighted you can navigation between the assistant editors with the arrow keys and press Return on the new editor to make it the active one.

This is image title

Fix All Errors In-Scope

I often come across scenarios where Xcode throws a lot of errors at me, specifically related to Swift syntax — which is common when you’re migrating across different versions.

Luckily the Fix-it All at once option works well for most of the general errors and saves us a lot of time, especially in huge projects.

Shortcut: ⌃+ ⌥ + ⌘ + F

( Control + Option + Command + F)

This is image title

Multiple Cursors on Multiple Selections

Often, there’s a need to use multiple cursors to avoid typing/copying the same thing on different lines. We can do that by selecting the current word and pressing Alt + Command + E to select the next occurrence(s). This places multiple cursors on the words and allows us to edit them together.

Shortcut: ⌥ + ⌘ + E

(Option + Command + E)

This is image title

To select the previous occurrence, Shift + Option + Command + E is used.

Refactor All In Scope

Refactoring is inevitable. That makes editing variables and methods in the scope a crucial tool. The following shortcut lets us edit all in scope together at the same time:

Shortcut: ⌃ + ⌘ + E

( Control + Command + E)

This is image title

Jump to Method

In order to look at the outline of your file, the methods present, simply press Command + 6. It opens a jump bar from where you can search the desired method and you jump directly to it.

Shortcut: ⌃+ 6

(Control + 6)

This is image title

Jump to Definition

Since Xcode 9, command+click doesn’t directly take you to the definition. Instead, it shows you a pop-up hint with a list of options. In order to directly jump to the definition without seeing the pop-up use the following shortcut:

Shortcut: ⌃ + ⌘ + J

( Control + Command + J)

This is image title

Fold and Unfold Methods

When your file sizes are going out of bounds (which ideally they shouldn’t) there’s a handy shortcut that lets you do code folding and collapse all methods/selective methods.

It puts a code ribbon on each enclosing block. Following are the shortcuts for the different cases:

Fold All: ⇧ +⌥ + ⌘ + ←

(Shift + Option + Command + Left Arrow)

Unfold All: ⇧ +⌥ + ⌘ + →

(Shift + Option + Command + Right Arrow)

Fold Current Block: ⌥ + ⌘ + ←

(Option + Command + Left Arrow)

This is image title

Closing Tabs

Xcode has a lot of shortcuts that let you choose the tab you want to close. It can be the current one or all but the current one. The shortcuts for each of the use cases are given below:

Close Tab: ⌘ + W

(Command + W)

Close Other Tabs: ⌘ + ⌥ + W

(Command + Option + W)

Reorder Statements

To change the order of statements and to move them over one another the following shortcut is used:

Shortcut: ⌘ + ⌥ + ( ] or [ )

(Command + Option + Square Brackets)

This is image title

Find Call Hierarchy

To quickly find the call hierarchy of the selected symbol, be it a method or an instance, just use the following shortcut. It opens the call hierarchy in the project navigator.

Shortcut: ⇧ + ⌃ + ⌘ + H

(Shift + Control + Command + H)

This is image title

Global Search And Or Replace

Xcode IDE has the ability to do a quick global search and even has the ability to replace the symbols everywhere (handle with care).

Search in the whole project: ⇧ + ⌘ + F

(Shift + Command + F)

Search & Replace in the whole project: ⇧ +⌥ + ⌘ + F

(Shift + Command + Option + F)

This is image title

SwiftUI Previews

SwiftUI has changed the way we think and build UIs. With a built-in canvas preview in Xcode, building UI through code or directly in the previews has just got a lot easier. The shortcuts are just the icing on the cake to speed up your development process.

Toggle canvas

If you’re looking to quickly build a prototype in code without letting the live previews distract you until its done, this is a handy shortcut.

Shortcut:⌥ + ⌘ + ↩

(Option + Command + Enter)

Resume automatic previews

Often the automatic preview pauses and requires us to manually resume it. Xcode 11 gladly has a shortcut for this.

Shortcut: ⌥ + ⌘ + P

(Option + Command + P)

This is image title

Minimap Shortcuts

Xcode 11 gave us minimaps. A much-needed outline view of your code on the right-hand side of the IDE. By hovering over it you can navigate to any part of your code.

Among the important shortcuts, one lets you toggle the minimap view while the other shows an outline of all the properties, methods, classes and blocks of code in the file:

Toggle Minimaps: ⇧ + ⌃ + ⌘ + F

(Shift + Control + Command + F)

Minimap Outline: ⇧ + ⌃ + ⌘

(Shift + Control + Command)

This is image title


We’ve had a quick tour through a lot of Xcode shortcuts that can increase your productivity and speed by leaps and bounds. Xcode 11 has introduced some handy utilities and shortcuts that should only help you accelerate your work.

For developers getting started with shortcuts, I’d recommend to take it slowly. Choose a few shortcuts and include them in your daily use cases to build up that muscle memory. Trying to memorize everything at once isn’t the optimal way to master keyboard shortcuts.

That’s it for this one — thanks for reading!


What's New in Xcode 11?

Top 4 Programming Languages to Learn In 2019

Introduction to Functional Programming in Python

Dart Programming Tutorial - Full Course

There Is No Best Programming Language

Top 4 Programming Languages to Learn in 2019 to Get a Job