It's important to know an application inside out when you spend a lot of time in it.
And for most iOS & Mac developers, Xcode is the application they spend virtually all of their time in.


In this article, we've compiled 6 tips that help you become more productive with Xcode.


1. Decide Where to Open a File

In Xcode, you can open a file in various ways: in the standard editor, in a new or existing assistant editor, in a new or existing tab, or in a new window. Here’s how you can decide about this:

  • When clicking on a file in the Navigator, hold down SHIFT + OPT
  • When clicking on a symbol in an editor pane, hold down SHIFT + OPT + CMD

A pop-over will appear and let you choose where exactly you want this file to be displayed:

image

2. Open Quickly

You shouldn’t waste your time digging for a file in your folder hierarchy. Instead, you can use Xcode’s “Open Quickly” dialog (CMD + SHIFT + O). Simply start typing any part of the file’s name - it doesn’t even have to be consecutive letters: “mwinco” will find your ”MainWindowController” class.

As if this wouldn’t be cool enough, this dialog also lets you decide where exactly to open the file: hold down CMD + OPT + SHIFT while double-clicking the file to open.

Read more about the “Open Quickly” feature in Apple’s documentation.

3. Custom Code Snippets

Whenever you find yourself typing the same bits of code multiple times, you should create a code snippet. To do that, first make sure that the “Code Snippet Library” pane is displayed (CMD + OPT + CTRL + 2). Now go back to your editor pane and start typing what will soon be a custom snippet - and remember to insert placeholders for values you have to fill out when invoking the snippet (e.g. <#token#>). Then highlight and drag that code to the library pane. Besides from naming it, you should also define a “Completion Shortcut”: when you type these letters later, Xcode will offer to substitute them with your custom snippet.

image

Read more about custom code snippets in Apple’s documentation.

4. Tabs

Tabs are well-known from almost every IDE and text editor. However, two things make tabs in Xcode especially powerful:

a) You can configure each tab individually. For example, one tab could contain just two editor panes, while another one could contain the project navigator, a single editor pane, and the utilities area. Thereby, you can configure tabs that are optimized for different use cases (like coding, debugging, interface builder tasks, …).

b) Tabs are persisted in a workspace. When opening the project again, Xcode restores the tabs - including their unique structure. This makes it worth while to take some time to configure your “perfect” setup.

c) By double-clicking a tab, you can assign it a name. Named tabs can then be used in “Behaviors” (see below).

Read more about tabs in Apple’s documentation.

5. Behaviors

With “Behaviors”, you can tell Xcode how to react when certain events happen. For example, you could have the console view shown whenever your app starts running; or you could have a new tab opened whenever you start a search.

This gets even more powerful when combined with named tabs. For example, whenever your app pauses, you can have Xcode open your named tab “Debug” - a tab that you configured exactly how you want it to look (maybe with an assistant editor and the debugger shown, but the project navigator hidden…).
Behaviors can be configured in Xcode’s preferences window.

image

Read more about behaviors in Apple’s documentation.

6. Tests

In Xcode 5, the Navigator pane on the left offers a new “Test” tab. You can now execute individual tests very elegantly by using the little arrow buttons:

  • All tests in a certain file (arrow button on the right side of the Navigator)
  • A certain test method only (in the line number column directly in the file)

image

Read more about the Test Navigator in Apple’s documentation.




Also have a look at our cheat sheet for Xcode. It includes the essential keyboard shortcuts and these tips - and is free to download!