Five Xcode Tips To Speed Up Your Development
Xcode is a pretty complex piece of software and it changes with every major release. Apple's IDE (Integrated Development Environment) has dozens and dozens of tiny secrets, which you only discover the more you use it. In this article, I would like to share five tips that I use every day and could not do without.
1. Named Tabs
My guess is that you already use multiple tabs in Xcode. Did you know that you can assign names to tabs? Named tabs are very convenient and much easier to manage. You can name a tab by selecting the tab and double-clicking its name.
Whenever I work in Xcode, I have at least two named tabs, Console and Trace. As its name implies, Console is dedicated to monitoring Xcode's output. I use Trace for stepping through breakpoints. With named tabs, I don't waste time searching for the tab I need. Xcode behaviors make named tabs even more powerful.
Behaviors are another powerful feature of Xcode. With behaviors, you tell Xcode what to do when a particular event takes place.
How often do you open the console when you are debugging an application? I have a separate window with a tab named Console, which I tell Xcode to open whenever output is generated. The possibilities are endless.
Whenever a breakpoint is hit during a debug session, Xcode automatically shows me the tab named Trace and opens the Debug Navigator. To make debugging easier, I also tell Xcode to show the debugger at the bottom of the window.
3. Navigating Tabs & History
In Xcode, each tab has its own history. While it can be useful to click the Go Back and Go Forward buttons in the top left of the editor, it is much easier to create keyboard shortcuts or trackpad gestures for these common actions. Once you start using this feature, you find yourself using history all the time.
History has the tendency to repeat itself. Take advantage of Xcode's Go Back and Go Forward commands to save yourself time and frustration. I also use keyboard shortcuts to navigate between tabs, which makes this feature even more powerful.
4. Code Snippets
You create a code snippet by selecting the block of code you want to create a code snippet for and dragging it to the Code Snippet Library on the right. Xcode's code snippets are great because of two features, context and placeholders.
You can add multiple placeholders to a code snippet. This is great for filling in the gaps of the code snippet. You can also define the context in which Xcode should show a code snippet in the autocompletion menu.
If Xcode's code snippets are new to you, then I encourage you to give them a try.
5. Smart Breakpoints
Breakpoints are indispensable for debugging. But did you know you can assign actions to breakpoints. Each breakpoint is configurable in several ways. You can, for example, tell Xcode to ignore a breakpoint until it is hit a set number of times.
You can even trigger log messages or sounds whenever a breakpoint is hit. This is very useful if you don't want to pause the application every time a breakpoint is hit.
Give it a try. Select a breakpoint, right-click, and choose Edit Breakpoint.
What are your favorite tricks to speed up your work in Xcode. Leave them in the comments below or reach out to me on Twitter.