Leopard Developer Tools Overview

Tools for your imagination

The developer tools in Mac OS X Leopard are crafted for one mission: to enable you to create amazing applications. Offering a streamlined workflow, Xcode 3.0 helps you develop your applications faster than ever. The all-new Interface Builder lets you build awesome user interfaces that take full advantage of Leopard's capabilities. The new language features in Objective-C 2.0 speed up your development cycle. The innovative new Instruments brings the ability to visualize your application at runtime in a way that's never before been possible. And, the brand-new Dashcode makes it a snap to create elegant and powerful Dashboard widgets.

As the second installment in the Leopard Technology Series for Developers, this article provides a preview of what you'll find when working with the new tools. First, let's look at how the developer tools are going to streamline your workflow.

Streamlining Your Workflow

As a developer, you know how important it is to focus directly on what you are working on and to minimize other distractions. From its inception, Xcode was designed to remove distractions and let you stay heads-down in your code, not lost in extraneous details. Xcode 3.0 takes that vision even further with features and enhancements that help make sure your focus is on your code.

To start, we've improved the source code editor. Syntax highlighting and code completion are improved in both quality and speed. More symbols in your code are identified and you'll have more flexibility in their coloring. In addition, the ability of the editor to handle large files is drastically improved, with performance up to 5 times faster than the previous version of Xcode. This improvement in performance means that your day will run a bit more smoothly.

Figure 1: Xcode highlights blocks of code to help you see how your code is structured.

Figure 1: Xcode highlights blocks of code to help you see how your code is structured.

As you work in the editor, everything revolves around the cycle of adding code, compiling it, running the built executable in a debugger, editing your code to eliminate problems, and then recompiling it until you get it right. Xcode 3.0 improves this experience radically. Traditionally, when you compiled code you had to go hunting through a stack of windows to see any compilation errors and warnings and then you jumped to the affected lines. In Xcode 3.0, these errors and warnings are displayed right in your code window as message bubbles. You don't have to move your attention to a different window when a build error occurs. You are given a direct pointer to where the problem is so that you can fix it immediately and move on, all while staying within the editor.

Figure 2: Xcode shows build errors and warnings using message bubbles.

Figure 2: Xcode shows build errors and warnings using message bubbles.

After you've successfully compiled your application, the next step is to run it. When you do so, the very same editor that you've been working in serves as your view into the internals of the application as it runs in the debugger. You can add, remove, and change breakpoints using the editor and inspect the current values of variables by hovering your mouse over them in the source code.

Figure 3: The Xcode editor allows you to directly work with breakpoints and inspect variables.

Figure 3: The Xcode editor allows you to directly work with breakpoints and inspect variables.

To help you further minimize distractions as you work, we've added powerful code folding features to the Xcode editor. You can easily highlight and then fold any block of code in your source code.

Figure 4: You can easily shrink blocks of code so that you can focus on just the methods you want to see.

Figure 4: You can easily shrink blocks of code so that you can focus on just the methods you want to see.

As you build an application and take advantage of the various APIs and frameworks Mac OS X provides, having immediate access to documentation is critical. The new Research Assistant in Xcode provides immediate and context-sensitive information about the code that you are working with. As you move around your code, it follows along providing just the information you need as you need it. And, when you need to dig deeper into the documentation, you can easily do so.

The bottom line is that Xcode 3.0 provides a fantastic environment for doing what you do all day long: develop code. Just like all the other applications on Leopard, it has been designed to be easier to use and more visually pleasing to work with. But we didn't just improve the source code editor, we improved the source code as well.

Working Faster with Objective-C 2.0

The Objective-C language, which provides much of the power behind the Cocoa framework, has been significantly updated for Leopard. Objective-C 2.0 introduces automatic garbage collection, fast iteration over collections, and powerful declared property accessors.

The new garbage collector is a tuned, high-performance implementation that makes tedious memory management in Cocoa applications a thing of the past. It works hand-in-hand with the strengths of Objective-C, allowing you to never worry about memory management of Cocoa objects, yet allowing you full access to C-based structures and functions that use malloc and free or reference counting systems. And, it's an opt-in system. This means that if you have an existing codebase that you want to run unchanged in Leopard, you don't have to do a thing.

Of course, the question that many developers will have about the new garbage collector is: "How fast is it?" It's a valid concern as you don't want a garbage collector introducing pauses into your application or otherwise slowing it down. Well, you don't need to worry. We've made sure that the garbage collector performs well in a variety of situations. In fact, Xcode 3.0 has been updated to use garbage collection.

Fast iteration lets you operate across all of the members of a collection simply and easily without first obtaining an Enumerator object. For example, if you wanted to iterate over an array of strings, you can do the following:

for (NSString *string in array) {
  NSLog(@"string is: %@", string)
}

Adding properties to a class typically requires writing a bit of boilerplate code to access and possibly set the property. The new declared properties feature of Objective-C 2.0 let you eliminate tedious accessor methods from your code. You can easily define the name and type of a property, as well as whether it should be read-only or not, on a single line of a class's header file. For example:

@interface Person : NSObject {
}
@property(ivar, readonly) NSString *name;
@property(ivar, readonly) int age;
-(id)initWithName:(NSString)name age:(int)age;
@end

Using a property is simplicity itself. For example, to access the age property of an object instance of the Person class above:

int age = mike.age;

Thanks to its dynamic runtime and excellent integration with C and C++, Objective-C has long enabled major productivity gains. These new features in Objective-C 2.0 are going to make it that much easier and faster to create and maintain Leopard-based applications. Now, let's turn our attention to a new tool that will help you see how your application behaves as it runs.

Creating Richer User Interfaces

A feature of the Cocoa framework is the creation of user interfaces in nib files rather than in code. Created and edited by Interface Builder, nib files comprise a set of interface objects and their relationships, as well as their connections to your application's logic. In Leopard, Interface Builder has been modernized to give it a more natural workflow, with added support for new Leopard user interface features.

Figure 5: Interface Builder 3 offers a modernized  design that lets you build your UI faster than ever.

Figure 5: Interface Builder 3 offers a modernized design that lets you build your UI faster than ever.

Using Interface Builder in Leopard, you'll be able to add impressive Core Animation-based behaviors to your application in a matter of minutes. You'll be able to easily†add transition effects between UI states, or 3D shadows to your controls, by simply clicking a few buttons in Interface Builder.

The new Interface Builder uses Leopard technology to look great, smoothly re-ordering your collection of UI controls and making the controls visually "pop-out" when dragged from the library to your UI. You can perform searches on the user interface element library to find just the component that you need. And it comes with a new Interface Builder Kit API for plug-in developers to provide their own user-interface elements to application builders.

Visualizing Your Application

Performance monitoring tools have long been an essential part of the developer's toolset. The limitation with those tools, however, is that they have only been able to give you part of the picture of how your application runs. Selecting the best tool for the job could be tricky, and there was no easy way to compare data between tools to see a complete picture of the behavior of your application. Instruments, new in Leopard, changes all of that. It allows you to view multiple aspects of your application's performance over time. With time-based graphs, you can monitor CPU usage, disk I/O, memory usage, and how they interact. This will give you a more complete picture of the behavior of your application.

Figure 6: The Instruments interface provides a time-based instrumented view of an application.

Figure 6: The Instruments interface provides a time-based instrumented view of an application.

Instruments borrows a cue from music editing applications where multiple instruments perform over time. It allows you to select just the instrumentation that you need to examine your application. For example, you could set up instruments to monitor both object allocation and garbage collection. Then, when you run your application, these instruments present their findings alongside each other so that you can see the relationships between the two.

Watching your application's performance in real-time is only the start of Instruments's capabilities. Once the data has been recorded, you can move back and forth through the application's timeline and closely examine the recorded data. This lets you exercise your application as a user and then later roll back through the recorded data to narrow your focus to see exactly what happened and when.

Experimenting Freely

Being able to manage multiple revisions of your source code is essential to the smooth development of an application. Source code control systems—such as Subversion, CVS, and Perforce—give you this ability and have long been supported by Xcode. Complementing these centralized source code control systems, Xcode 3.0 adds a new feature, Project Snapshots, to enable a more short-term approach to working with your code. Using Project Snapshots, you can mark a point in time in your code and then experiment any way you'd like knowing that you can immediately revert the state of your project back to your snapshot. For example, you can snapshot your project before totally rewriting the way a method works. If you decide the approach you took wasn't the right one, you can snap back in time and try a different approach.

Figure 7: Snapshots let you quickly try something and then revert just as easily.

Figure 7: Snapshots let you quickly try something and then revert just as easily.

To allow you to work more rapidly and effectively, Xcode 3.0 offers support for re-factoring your Cocoa applications. This means you can now make structural changes to your source code without accidentally changing its behavior. Instead of performing multiple search and replace operations, you can rename an instance variable and update all of the methods that work with that variable, including indirect access through KVC style methods. This re-factoring support extends beyond your source code and will even update bindings set in your nib files.

Accessorizing with Widgets

Dashboard widgets have become an essential addition to the ecosystem of Mac OS X applications. They provide a mechanism for users to perform common tasks and get fast access to information. Widgets associated with an application enhances the user's experience of that application by providing a simple, and typically read-only, interface that is quick to use. Based on the Web technologies of HTML, JavaScript, and CSS, widgets are quick to build and easy to modify. To make it even easier to create a widget, Leopard's developer tools include the all-new Dashcode.

Dashcode provides a powerful interface to create, edit, and debug widgets. It takes care of all of the work of managing a widget's package structure and provides a test runtime environment so that you can run your widget without loading it into your Dashboard. It also provides a visual layout environment to make it easy to tweak your widget's appearance.

Figure 8: Dashcode provides a powerful GUI-based IDE for creating widgets.

Figure 8: Dashcode provides a powerful GUI-based IDE for creating widgets.

To get you started, Dashcode provides several common starter templates, ranging from a basic "Hello, World" to a complex system monitoring widget. All of these templates give you a front and rear canvas to layout your widget's user interface, an icon, and all of the necessary HTML, CSS, and JavaScript files to get started. By taking care of these common elements, Dashcode makes it easy to focus on what will make your widget unique.

Get Started with Leopard

The next generation of the world's most advanced operating system is now available.†Tap into the innovative†technologies†of Mac OS X Leopard and design your products with new and compelling features.†With an†ADC Premier or Select Membership, you have a range of developer resources from Apple†engineers and experts, including ADC on iTunes, Coding Headstarts, the ADC Compatibility Labs and more. Learn how ADC Memberships provide you Apple expertise. From code to market.

Updated: 2007-10-26

 
 
 

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2009 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice