Xcode shortcuts
Learning Xcode keyboard shortcuts will improve your workflow, productivity and make you a faster iOS or Mac app developer. There are many keyboard shortcuts in Xcode that can make yourself a more efficient developer.
Knowing the Mac keyboard symbols
Sometimes the Mac keyboard symbols are a bit confusing. Let's first get familiar with the keyboard keys to use for shortcuts thus we should be able to clear things up for anyone who has difficulties in recognising the Mac keyboard symbols.
Symbol | Name |
---|---|
⌘ | Command |
⇧ | Shift |
⌥ | Option/Alt |
⌃ | Control |
⇠ | Left Arrow Key |
⇢ | Right Arrow Key |
⇡ | Up Arrow Key |
⇣ | Down Arrow Key |
⇥ | Tab |
⎋ | Escape |
↩ | Return |
Basic Shortcuts
Here’s a list of the most common shortcuts used in Xcode:
Command | Key combination |
---|---|
Build | ⌘B (command + B) |
Run | ⌘R (command + R) |
Test | ⌘U (command + U) |
Stop | ⌘. (command + .) |
Clean | ⌘⇧K (command + shift + K) |
Clean the build folder | ⌘⇧⌥K (command + shift + option + K) |
Open quickly | ⇧⌘O (shift + command + O) |
Code completion | ⌃Space (control + Space) |
Show / Hide navigator | ⌘0 (command + 0) |
Show / Hide inspector | ⌘⌥0 (command + option + 0) |
Show / Hide debug area | ⌘⌃Y (command + control + Y) |
Show / Hide Minimap: ⌃⇧⌘M (control + shift + command + M)
Minimap is one of the most anticipated features introduced in Xcode 11. It is a bird’s eye view of our code and it is meant for navigation. By using minimap, we can easily and accurately navigate to any part of our source code. Therefore, toggling(show / hide) the minimap easily can definitely improve our productivity.
Show Library: ⇧⌘L (shift + command + L)
This shortcut will show library of code snippets, image assets and color assets. On the other hand, when used in storyboard, it will shows library of UI objects, image assets and color assets. We can use this shortcut in storyboard to quickly bring up the UI objects library and add the desired UI object into storyboard.
Show Document Items: ⌃6 (control + 6)
This shortcut is especially powerful when we want to navigate through a long source code. What we can do is to use this shortcut to bring up a list of document items, start typing to filter the list, then select our desired document item to jump to the respective source code location.
Highlight File in Project Navigator: ⇧⌘J (shift + command + J)
I usually use this shortcut along side with the quick open shortcut (⇧⌘O). The trick is to use the quick open shortcut to search for the desired file, open it in the editor, after that hit ⇧⌘J to quickly highlight the file in the project navigator. Note that this shortcut also works on the secondary source editor.
Go to Line: ⌘L (command + L)
During a code review session, our fellow colleagues might need us to improve or rework on a specific line of code. In this kind of situation, this shortcut can help us quickly navigate to the exact line of code that we need to rework.
Switching Tabs: ^⇥ (control + tab)
Tab is one of the most commonly used features in Xcode. This shortcut allows us to switch tabs from left to right.
Pro tip: Use^⇧⇥ to switch tabs from right to left.
Show / Hide Preview: ⌥⌘↩ (option + command + enter)
I found this shortcut extremely useful when working on a SwiftUI file. Hitting this shortcut enables us to have a quick UI preview of our current SwiftUI code. Furthermore, we can also use this shortcut when working on storyboard.
Show / Hide Assistant: ⌃⌥⌘↩ (control + option + command + enter)
Sometimes when I am using Objective-C for iOS development, I always use this shortcut to open the assistant editor so that I can work on both .m and .h file side by side. Nowadays, I mainly use it alongside with storyboard especially when I want to make an IBOutlet connection to the source code, or do a quick updates on my source code while working on storyboard.
Show / Hide Code Review: ⌥⇧⌘↩ (option + shift + command + enter)
Sometimes we might need to have a quick look on the changes we have made on our code. Use this shortcut to quickly switch to code review mode and have an overview on what we have changed, once done, just hit the shortcut again to switch back to normal source editor mode.
Conclusion
To be able to use all these shortcuts proficiently might seem a bit staggering at first. However, once you started using them you will notice being more productive and faster in your day-to-day development work.
Keep practising.