Easy Tips and Tricks to Help You Xcode Better
These hotkeys, tips, and tricks for the Xcode mobile development environment will make your life easier and your app development speedier.
Join the DZone community and get the full member experience.Join For Free
Where developers are concerned, Xcode is still far from being perfect. However, the toolset software has undergone several changes and still manages to improve with each new iteration that is released in the market for the developers.
First and foremost, it is important to have a keyboard cheat sheet before we go into the fun part of the tips and tricks. Here is a list of the cheat sheet:
⌘ is Command
⇧ is Shift
⌥ is Option
⌃ is Control
Now that we have the heat sheet ready, let us now take at the list of tips and tricks that almost everyone, from the beginner to the veterans, can use to make coding easy and pleasurable.
The next step is to learn about the shortcuts that are immensely useful, but somehow not that much in vogue.
The ⌥ Option + ⌘ Command + / shortcut for documentation.
A developer might choose to document what he or she is doing for future reference or even coaching newcomers. Some parts of the code can turn out to be a bit too complicated, and therefore, if you ever need to revisit it for some other project, you can always use the shortcut to leave a quick note. To do this, you must go to the right, above the symbol. Next, press ⌥ Option + ⌘ Command + / After you do this, the Xcode will mark it.
⌘ Command + ⌃ Control + E shortcut for edit all in scope
Even though code refactoring is not one of the biggest reasons why iOS developers use the Xcode, its value is surely being recognized in the coding field nowadays. You can change the name of the function or even the variable with the help of this handy little shortcut. To do this, you must select the word that you need to change press the ⌘ Command + ⌃ Control + E keys. Upon doing so, you will detect a dotted frame surrounding the text that has been selected. Now, you can change whatever you want to within this dotted line. The code will be immediately updated and work accordingly. This is also a much safer, and not to mention, quicker, option than the search and replace option.
The ⌘ Command + ⇧ Shift + J shortcut for revealing in Project Navigator
If you ever need to find out where is the location of the file that you are working on and how to access it safely, then this shortcut is a definite life saver. If you press the ⌘ Command + ⇧ Shift + J keys, you will see it as a selected option in your project navigator.
The ⌘ Command + ⌥ Option + , shortcut for opening in other editors
As mentioned, using this shortcut by pressing the ⌘ Command + ⌥ Option + , can help you open the current coding file into the Assistant Editor from the standard editor. The switch wastes no time as it is pretty quick to load and operate.
The ⌃ Control + 6 for searchable Menu control
This code is immensely useful if you are working on a code that has a big class with so many methods that you have lost track of them. To avoid such a problem, press the ⌃ Control + 6 keys for searching these methods as you wish and correct them as you please.
Xcode is full of tricks that you need to be aware of to unlock its full potential. Here is a list of features that are immensely helpful, but you may not be aware of them:
- The Git Blame
Sometimes, when you run a fully completed code, there can be a line error which prevents the code from working. In order to find out what did that or who did that, its always best to use this feature. Simply choose “Show Blame for a Line” and the results will appear immediately.
- Deciding where to open a particular file
Although you have multiple ways to open a file in Xcode, you have no surefire way of opening the one which contains the code you need. To find the code you require and minimalize the rest of the junk, here are some ways:
- Press the ⌘ Command + ⇧ Shift + O using Open Quickly.
- While holding down the file you require, hold down the ⌘ Command + ⇧ Shift + ⌥ Option.
A small window will appear for you to search for the code and it will appear instantly.
- Variable Breakpoints
If you want to find out the exact moment when a variable is modified, just add a breakpoint on the line where you have declared an instance. Xcode will stop and inform you every time the variable is modified.
Above is the basic guide to coding using the Xcode. These tips and tricks will surely make using Xcode efficient and time-saving.
Opinions expressed by DZone contributors are their own.