Mastering Xcode Shortcuts

Karthik
5 min readSep 27, 2021

--

Sometimes taking time is a shortcut.

Developers often spend most of their time on an IDE. If you are an iOS developer, you would probably be closer to your Xcode IDE than anything else at work.

Shortcuts are an extremely useful feature in almost any software. In IDEs a user needs to input a lot of commands (aside from the code editor itself). Nevertheless, it’s also really easy to abuse them.

If your job requires you to be working with an IDE for eight hours a day, then using keyboard shortcuts will be the best option to save you tons of time every year.

Xcode has keyboard shortcuts for most of its commands related to editing, navigation, refactoring, debugging, and other tasks. Memorizing these hotkeys can help you stay more productive by keeping your hands on the keyboard.

Top 10 XCode Shortcuts

Here are my top 10 XCode keyboard shortcuts that I use on a day-to-day basis.

1. Clean: ⌘ + ⇧ + K

To clean the build you can use the shortcut Cmd + Shift + K or
Menu Bar → Product → Clean. This one is useful when you’re sure that the code you wrote is good, but because of the Xcode cache, some errors were thrown. in such case clean the project (⇧+ ⌘ + K) and run it again. which will clean the build and make a new build from scratch next time when you run the code.

2. Build: ⌘ + B

Xcode auto checks for the errors with defined intervals, sometimes it can be delayed or there could be a cache issue. To avoid those edge cases we often use this command to make sure that the code we wrote is building without any issues.

We don’t always have to run the app if you are making minor changes, and that’s where building can help you do a quick check so that you can get back to adding the next line of code.

3. Run: ⌘ + R

Once everything is done and you are ready to see the results. Just hit ⌘ + R which will run your code followed by invoking the simulator to show the results.

4. File Search: ⇧ + ⌘ + O

Finding one particular file in a massive project with tons of files is hard. That's where ⇧+ ⌘ + O can help in searching the entire project. We use this shortcut millions of times a day. It lets you just type and jump to a method definition or a specific code file.

5. Project Search: ⇧ + ⌘ + F

Find all the times you mentioned a variable or method name with the project search. You can match based on the case, or ignore upper and lower case letters.

You can also replace all occurrences of a variable name with a new variable name.

6. Console: ⇧ + ⌘ + Y

Running the project auto opens the console area once it's succeeded. Sometimes console can take 20% of the screen, and for a 13' screen it's huge. Using a mouse every single time to hide the console is an absolute pain.
With ⇧ the + ⌘ + Y shortcut we can toggle the console back and forth.

7. New Tab: ⇧ + ⌘ + T

We can’t always work with a single file. Most of the time we might need multiple files to be opened. Again the use of a mouse to open a new tab is hard. just by simply pressing ⇧+ ⌘ + T can get us the new tab.

8. Close Tab: ⇧ + ⌘ + W

The reverse of the tab creation. Not only for Xcode, we often use this ⇧+⌘+W in all the apps like chrome, safari, etc. When you are done with your work or about to sleep, this command can help you unwind quickly.

9. Fold: ⇧ +⌥ + ⌘ + ←

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:

Shortcut Customization

https://karthikmk.medium.com/xcode-custom-behaviours-99e1743321d4

XCode allows you to customize and define new shortcuts. With the help of Custom Behaviors, I have created two more shortcuts to perform a few operations. Click here to know more about Xcode shortcuts.

  • Pod install: ⇧ +⌘ + P
  • Open finder: ⇧ +⌘ + F

Ensure that you are not violating your existing muscle memory. We often use cmd + shift + O for searching inside the project. Choosing this shortcut for any other shortcut can violate your muscle memory.

Note: We should remap everything whenever the Xcode update happens.

Final Thoughts

From personal experience, I would suggest that every shortcut you use should come naturally to you as a part of your daily typing. k Keyboard shortcuts must be memorized by your hands and not by your mind like touch typing skills. Sometimes I don’t remember the shortcut but my fingers do.

That’s it for this time! Feel free to comment if you have questions and follow to get notifications about future articles.

“Be the senior engineer you needed as a junior.” — Someone

👏👏👏👏👏👏👏

--

--

Karthik
Karthik

No responses yet