Xcode and Interface Builder 3: A Brief Overview

Author: David Gohara
Web Site: gohara.wustl.edu

Many of the developer tools have undergone a significant revamp in Mac OS X Leopard. The new version of Xcode 3 has been retooled to significantly streamline a developers workflow when building and using Xcode based projects. Interface Builder 3 is a complete rewrite and sports a number of really nice features that make building interfaces for your applications a breeze. In this brief overview, I'll cover some of the more significant changes in both applications.

When you first start up Xcode you are now greeted with a functional splash screen that presents handy information for developers


Getting Started - A list of links to resources and documentation for getting started with the Apple Developer tools
Xcode News - An inline RSS reader for getting up to date information, Technotes, Sample Code and announcements regarding development on Mac OS X
Documentation - Quick access to Xcode documentation, tips and other featured information
Mailing Lists - Quick access to many of the Apple mailing lists, with a shortcut that will take you to the full list via your browser
Feedback - Quick links to the various feedback mechanisms (including bug reports and access to DTS)

You can set the window to not appear at launch and it can be accessed at any time via the Help menu.

The overall layout of an Xcode project remains the same, with a number of notable differences in how information is presented.

Syntax Coloring

The default syntax coloring of variables, methods and types has been revamped to include dynamic syntax coloring of your own methods and variables.


I've been using Xcode 3 for so long now, I can't remember what it was like not having all of the syntax coloring options. But one of the really nice about the new coloring mechanism is that it's a quick way to make sure you've spelled out methods correctly. If a method doesn't change from black (or whatever your default text color is) to magenta, then most probably the definition is wrong. Global variables are highlighted as well and code completion recognizes your custom variables and methods you define in your source.

Code Folding

A feature that has existed in other applications (such as Textmate) now comes to Xcode. You can quickly and easily fold blocks of code to hide them. So for example when you want to quickly hide large blocks of text that you'll never read (like the Apple license information in sample code) you can simply fold it up and get straight to reading code.

Another great feature is nested highlighting (or more appropriately Focus Follows Selection) which can be enabled from View -> Code Folding. This is a very quick and easy way to graphically determine in real time what blocks of code form functional groups.


Info Panel

This has been reworked to present information in a more organized way. In particular, the build tab. Project settings are grouped by type and are collapsable making it easier to quickly locate important settings without having to do a search (of course you can still do that as well).


Objective-C 2.0

A number of utilities have been added to make bulk changes to code easier. One is for converting your code to Objective-C 2.0 syntax (which might include the use of fast-enumeration, dot syntax to access properties of an object).


You can also bulk refactor your code in cases where a simple Find and Replace All wouldn't be smart enough to catch the context of a change. For example, when you have a variable called restore and a method called restore, refactoring would determine that you might be attempting to change the method name and would only apply changes to method calls and not changes to the variable.


Snapshots

I'll talk about the Organizer in another article, but within the Organizer is the ability to make Snapshots of your project (without having a version control system in place). The nice thing about snapshots is that you can make a snapshot, work on a project making all kinds of mistakes or coding yourself down the wrong path and simply restore your project quickly and easily to a known working version. It's also a great way tool for discovering why your program "suddenly" stopped behaving the way it used to (again without using version control or having to make a formal commit to a versioning system). You can quickly and easily compare a snapshot with the previous version to get a list of all of the changes.


Version Control

So long command line tools. You can now quickly and easily set up a project repository directly within Xcode. From the Xcode Preferences, navigate over to the SCM window item. In the screenshot below I didn't set it up yet, but there is support for CVS, Perforce and Subversion.


Research Assistant

No, this isn't like Clippy the Microsoft Word assistant. Research Assistant is a floating Panel that dynamically pulls up relevant information from the API documentation about a method or function you are using. Start typing selectedObjects and the usage, history, availability and more are immediately available. This saves having to switch over to the new documentation browser to get a bit of information about a method you are about to use.


Reference Library

The Reference Library has been significantly improved in Xcode 3. For starters you no longer have to download reference docs for languages you don't care about (like Java). The layout is similar as before.


What's changed (and is much better IMHO) is the ordering of methods in the documentation itself. The tasks are still organized by groups (based on functionality or a set of methods for a class, for example). However once you get to the actual documentation of the methods, the organization is alphabetical. So you can quickly jump/scroll to a method based solely on the name, without having to search through the pop-up lists or finding the hyperlink for the method in the tasks group, or doing a full search of all similarly named methods in the API's.


Debugging

The debugging facilities in Xcode 3 are perhaps my favorite addition. Similar to the previous versions of Xcode, graphical debugging is supported using the debugger window. Aside from general improvements in the display of call stack variables and objects, the way most people would use the standard debugger window hasn't changed much.


What is really great about the new debugging options is that you no longer need to open the debugger to get access to state information about your running program. From the project editor window, you simply turn on a break point, Build and Go (you no longer have to select Build and Debug, it just does the right thing) and you immediately have access to all of the debugging information within your code.

In the example below, I set a break point, and started the application. You'll notice in the toolbar that you have controls continuing, stepping over, stepping in and stepping out, as well as the option to pull up the full debugger window and console. Even more important, by simply hovering the mouse over an object or variable you get all of the relevant information about that variable. You can hover over any variables, not just where the breakpoint is set and get the information you need.


Errors and Warnings

The previous versions of Xcode supported warning and error icons in the gutter. Before, however you had to click on the icon to be taken to another window that displayed what the issue was the compiler was objecting to. Now, in Xcode 3 message bubbles will appear inline in the code that tell you what the problem was. You can disable message bubbles (or set them for errors only or warnings only) in the Xcode preferences.


Interface Builder

As I mentioned before Interface Builder has been completely re-written. The new version is greatly improved over the previous version. So much so, that I find it almost impossible to use the older version anymore. The controls, ability to access information, hook up controls, everything is more intuitive and inline with how an Apple application should work. The only issue I had initially was breaking old habits that were developed as workarounds.

IB is now really used for building interfaces. From what I can tell you can no longer subclass an object within IB... Good. That feature was too confusing. Objects should be sub-classed in Xcode and instantiated, if desired, in IB. However, that doesn't mean that IB ignores Xcode, in fact code can now easily be synchronized such that new actions and outlets can be pulled over from Xcode without having to drag and drop a bunch of files into IB.


In the above figure on the right hand side is the new Library. IB palette items are organized hierarchically making it easier to access specific controls. Most of the icons haven't changed, but a few (notably the controllers) are different. When you select a control a brief description of its use is displayed.

The real workhorse panel, the Info panel, has seen a major reorganization for the better. Similar to the older version the first tab is describes the object, it's basic properties that you can graphically set and so forth. In this example we are looking at an Object Controller, so not much exciting stuff there.


The second tab has to do with the animation properties as part of the new technology Core Animation being introduced in Leopard. Here is where you enable Core Animation for objects that can be animated.


In the above figure we have:

Wants Core Animation - The views/objects are presented in a hierarchy, in this case we only have the main window. Controls attached to that window would display beneath it. You can enable animation layers here.

Appearance - Is where you can set basic properties of controls and views.

Content, Background and Compositing Filters - You can apply Core Image filters to controls and elements using a simple menu to select which filters you want to apply

Transitions - Transitions dictate how your animation will composite. These are similar to transitions in Keynote.

Size Tab

The size tab has a really nice new feature. The ability to see how a control will respond to restraints on the fly without having to run the Cocoa Simulator. The colored window in the Autosizing group gives realtime feedback for how a control will behave.


Bindings

Similar to the bindings window before, except that disclosure triangle states are remembered between tab switches.

Outlets and Actions

This is really nice, because it graphically shows you what outlets and actions are wired (in this case none are). But if they were it would also show you on the right hand side of the window what control or object the wired action or outlet connects to.


Indentity

The Identity tab is where you assign class information (for example if you want to assign a control to a custom subclass. You can also add and remove Actions and Outlets for the class.


AppleScript

And in the last tab is the ability to work in some AppleScript magic.


I should also mention the ways that you wire up controls and access outlets and actions. For every object in the nib you can access its outlets or actions by right clicking, which brings up the connection HUD. Connections are two way, so the relevant HUD will appear depending on the direction you connect.

Also, I should point out that you can now select multiple objects and change similar properties on those objects all at once. So if you want to disable 10 buttons, select them all, go to the first tab and un-check Enabled. That's a really handy feature.

Conclusions

Overall the new Xcode is a really big step forward. Personally, I like the functionality of it so much, opening projects in older versions of Xcode is painful. And IB 2.X has become completely unusable for me. That's not meant to be a slam against the previous IB, but rather strong praise for the decision to step back, and completely rework from scratch IB to make it a much more useful tool.

There are a few changes that will affect some of you MacResearchers though... The most glaring is that the gfortran we maintain and distribute, simply will NOT work in the version of Xcode. Not even, kinda, sorta... Not at all. But fear not, there is a new tool called Organizer which will probably fit the bill and in a later tutorial I'll talk more about it.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

ifort

I am glad that I couldn't quite afford to buy Leopard last friday. I would have been really upset to find that I couldn't compile my code using gfortran. Does Intel's compiler work with Xcode 3.0?

Re: ifort

Hi,

I don't have my installers handy, but I'll check here shortly. The last time I tried, the ifort plugin wasn't working properly (but that was in an early seed). I'm not certain if Intel or Apple provides the plugin. If it's Intel, then my version of compilers probably won't work. I'll let you know soon.

Thanks,

Dave

Xcode: Run or Go?

One thing I found confusing in the new Xcode, is that there are 2 ways to start your program, "Run" or "Go", and both have the same icon. The Go option will also start the debugger, which is nice when you need one, but which adds the overhead of starting the debugger before your program. To choose between Run and Go, use the Toolbar configuration sheet.

btw, one thing that is missing in the toolbar is the ability to open the "Console" window. Actually, it is only missing as an option in the main project window, but is available in the Debug window. I was able to force the Console icon to appear in the Project window toolbar by editing the plist file for Xcode in the Preferences. If anybody is interested in this esoteric setting, I could dig back into it and find exactly what I did!

Re: Xcode: Run or Go?

Hi Charles...

"btw, one thing that is missing in the toolbar is the ability to open the "Console" window. Actually, it is only missing as an option in the main project window, but is available in the Debug window."

Sort of... when you run your application (whether it's with "Build and Go" or simply "Go" the icon for the console appears just under the toolbar. It's a black square that looks like the "Console.app" icon.


You can also pull up the console from the keyboard using: shift-option-R

Or are you referring to something else?

Dave

Console icon in the toolbar

Thanks for that info, Dave. This is actually good to know, never noticed.

However, one may still want to open the console window when in the project window and the program is still running, and be dumb and lazy enough to forget the keyboard shortcut and not want to open the menu. And/or have habits from Xcode 2.x. Where it was possible to have the "Run" window icon appear in the toolbar. Since there is no more a Run window, and only a Console window (and that makes sense), and since there is no way to put the icon for the Console window in the project window toolbar, I had to find a workaround to force it in there (knowing that this toolbar icon exists and is available for the Debug window toolbar).

Here is what my project toolbar looks like. Can you get that icon up there too?

Re: Console icon in the toolbar

Hi Charles,

No I can't get it in the toolbar using the stand means (Customize Toolbar). I just retrained myself to open the console when the program is running or using the keyboard. I agree, though it is confusing (the change). But I got used to it, and I really like the inline debugger, so after a while I didn't note too much.

Dave

Toolbar craziness

When I think about it, it is kind of crazy that I went and poked in the plist file for Xcode preferences, just to get that icon up there, just to get my old setting the same way as before, when a keyboard shortcut is just as good. In fact, I usually like keyboard shortcuts better... I guess it is just hard to give away old habits.

Re: ifort

I checked in Xcode 3 using ifort 10.0.016 and it looks like the plugin for the Intel compilers isn't popping up as an option. So it's:

A) My version of the intel compilers (or the plugin provided with them) is too old
B) Apple didn't put in the plugin (if they are the ones that supply them)
C) Intel might be working on this now

I'll put in a few calls to see what the status is.

Dave

Re: ifort does work

Hi...

Ok. After upgrading to ifort 10.0.020 the plugin interface is there in Xcode. So you can definitely use that in Xcode 3.0 to compile fortran based projects.

Hope that helps,

Dave

Ada (and other languages) in Xcode 3.0

Does anyone have any insight into whether Ada will work with Xcode 3.0? I've asked this at the macada.org mailing list and it seems that there is a bit of catching up at the compiler level (my interpretation of what was said) but I still don't have a feel for what needs to be done to actually work within Xcode 3.0. Many of us have relied on the Ada plug-in reverse-engineered for Xcode 2.4 or similar, at

http://maxao.free.fr/xcode-ada-plugin/

General Xcode plug-in info is here:

http://maxao.free.fr/xcode-plugin-interface/

and the project, including information about several other language plug-ins, including Fortran, is here:

http://xcodeplugins.sourceforge.net/

Jerry