by Alex Rozanski

Xcoding made easier

Aug 20th 2009Published in Development, Tools

After the popularity of my post on the useful features of Xcode, titled Xcoding Made Easy, I decided to write a followup post detailing more features about the IDE which help make developing applications a much easier process.

Project Breakpoints


Breakpoints are a great convenience method for debugging your code. However, if you have lots of breakpoints, how do you manage them all easily?

When you add a breakpoint it appears in the Breakpoints folder in the Groups & Files list under Project Breakpoints. From here, you can turn breakpoints on and off and remove them, and change the conditions or add/remove breakpoint actions easily (from the accompanying detail view shown above the Editor pane) without having to navigate to each breakpoint directly. This is a great convenience for batch methods, such as removing all breakpoints.

Groups of breakpoints can also be created, by right-clicking on any number of breakpoints and selecting Group from the context menu.

Breakpoints for a specific source file can also be easily shown using the breakpoints popup list button in the Editor window, which lists the breakpoints detailing the method they are set in, and the line number that they apply to. Clicking on a breakpoint in the list will navigate to the source file and highlight the row that that breakpoint is applied to.

Class Navigation


Class navigation is a convenience for exploring the class hierarchy for a given class. It presents itself as a popup menu in the Editor window, which lists the superclasses, the class itself and any categories present on the class. The class that the menu displays information about is flexible: if the text caret in the editor window is within a class interface (between @interface and @end) or a class implementation (between @implementation and @end), the class navigation popup menu will provide information about that class.

This is a useful tool, especially when subclassing an existing class. Since subclassing builds on the existing functionality and implementation of a class (or classes), it may often be necessary to access inherited instance variables or provide custom implementations for inherited methods. By simply clicking on the class name of a superclass in the class navigation menu, you are taken to the superclass interface, which details the instance variables and methods which you can extend in your subclass.

Code Folding and Focus Follows Selection

As any Objective-C programmer knows, it is not the most concise language in the world – it is far from it, and it is so with some reason. However, this can make the readability of your source files difficult, especially if you are working with a class that has lots of methods implemented.

Code Folding and Focus Follows Selection are two options from the View menu which help to increase the readability of code. Code Folding is a way of folding functions and other braced parts of code into stubs, which makes the code dramatically more easy to read, whilst still providing the first line of a function or code block to show what the folded code is a part of. It can be applied from the View > Code Folding menu, with menu items to fold the code block that the text caret is currently placed in, unfold all items in the current source file, fold/unfold all methods and functions, and fold/unfold all comment blocks.

Focus Follows Selection is another feature used to help readability. When this is turned on, Xcode will highlight the block of code that the text caret is placed in (be it a method/function or other parenthesised block such as an if statement) and dim the rest of the editing area, making it easier to see in which block you are working. This can be very useful for nested loops or where there is nesting of braced pieces of code. It is presented as a checkable menu item in the View > Code Folding menu

Smart Groups

Smart Groups are a way of organising your project files based on a filter. Selecting Project > New Smart Group from the menu and then either Simple Filter Smart Group or Simple Regular Expression Smart Group allows you to create a Smart Group based on a wildcard expression (for example, *.nib would match all files ending in .nib) or a regular expression. You can also select where Xcode starts looking for files in the project folder hierarchy by changing the value in the “Start From:” dropdown box. You can then also select whether the group applies to all projects created in Xcode, or just the project that you are currently working on.

This is an easy way to keep your project(s) organised for you, which can reduce clutter across the Groups & Files list. As with all folders in the hierarchy in the Groups & Files list, it is purely virtual – that is, any items placed in Smart Groups will have no effect on their physical location on disk.

There are two Smart Groups that are present with Xcode by default – “Implementation Files” and “NIB Files”, which contain the project’s implementation and NIB files respectively.

Splitting the Editor View

Often it is useful to edit more than one source file at the same time, in the same editor window. This can be achieved easily by clicking on the Split Editor View button. This will add an extra editor view to the current window, resizing the other editor view(s) to fit. Then, when files are selected from the source list they will be loaded into the currently active editor view. There is an editor bar for each editor view (containing the history list, and method list etc) which is applicable to that view. There is also a resizing separator between the editing views to allow you to resize them.


Editor views can then also be easily removed by clicking on the Close Editor view button on that pane, located under the split editor view button for that editor view. This will resize the other editor views accordingly.

No comments

Add comment

Please enter your name and comment