Xcode 4 hands-on: be sure to RTFM first

Xcode 4 is probably the most significant change to Apple's developer tools …

When Apple bought NeXT, one of the things it was getting was a set developer tools: Interface Builder, used to construct the GUI; and Project Builder, which was used for managing code and resources. Combined, they enabled rapid application development. Although these tools were well ahead of their time when they were created, in many ways they'd fallen behind by the time they saw their first release from Apple. There have been some significant updates to the tools since, including the renaming of Project Builder to Xcode and the integration of iOS development, but these didn't fundamentally alter the behavior of the two applications.

Xcode 4.0, released Thursday, appears to be the most radical departure yet. It contains very significant changes and will require equally significant revisions to a developer's workflow. Still, the overall benefits look to ultimately be worth the effort. The new tools are so sprawling that it will be impossible to thoroughly review XCode 4 here; instead, we'll focus on its overall approach, and a few specific functionalities.

Major consolidations

One word to describe the previous incarnations of Apple's developer tools is "sprawling." If you needed to do performance monitoring, a separate tool—Instruments—had to be launched (Instruments had replaced a small collection of independent apps, so this was an improvement). To lay out the user interface, you needed a trip to Interface Builder. Keeping any files used by IB in sync with the code editing you did in Xcode was largely a manual process. Working within Xcode tended to spawn a collection of individual windows for code and data model editing, debugging, checking logged messages, and the like. Things got pretty cluttered very fast.

Apple had already taken some baby steps toward consolidation, integrating a minimal debugger into the main code editing window and producing Instruments. But overall, developing for either of its OSes required a huge assortment of dedicated windows and palettes.

There were some advantages to this, in that having windows that were specifically designed for a certain task tended to be better and more focused at accomplishing it. Xcode may have had window clutter, but those windows lacked some of the painful visual clutter that many development environments suffer from, with dozens of separate tool palettes vying for attention. Still, the juggling required to keep Xcode and Interface Builder in sync was a serious pain.

With Xcode 4, Apple has made a major effort at consolidation, and has attempted to balance window and visual clutter. Instead of independent windows for everything, the application now relies on tabs, each of which can be customized for a specific task. For example, it's possible to set up one tab for code editing, with a list of source files, a large editing area, and a small column of code snippets. Another can be set up for debugging, and a third to edit Core Data object models. It's still very easy to clutter one of the tabs up, but that's a user's choice, and the tabs do provide a nice way of avoiding window clutter.

The other major bit of consolidation is the integration of Interface Builder's GUI-editing abilities into Xcode proper. This takes a bit of getting used to—typically, doing anything in IB required at least two windows and a palette—but its implementation is pure, unadulterated goodness. You no longer have to take any special efforts to keep your class files in sync between the two applications. And, once you set up a tab appropriately, it's possible to directly modify code files using your interface layout.

It's just like IB, but all in one window.

Interface Builder has always relied on outlets, which provide a class reference to another object in the same IB file; and actions, methods that get triggered when the user performs an action like clicking a button. You can create and populate these in IB, but then you still have to ensure that the code file contains the corresponding items. Now, it's simple. Create an instance of your object in the IB file, and you can control-drag from anything else in IB to the header file for that object. Xcode will then ask whether you want an outlet or action, and populate the header file accordingly. This is a bit easier to see than explain.

It's incredibly simple to add an outlet for the "Open URL" contextual menu.

Overall, this consolidation is good. But it's a radical departure from the past, and it's impossible to shoehorn existing workflows into it. This is one case where RTFM really applies; unless you're willing to spend the time to familiarize yourself with the changes involved and experiment with the interface a bit, the new Xcode will probably get in the way of your productivity. And, even with the best of intentions, it's difficult to avoid having the new interface get very cramped and cluttered.