What's New in XCode 4

Xcode is the complete toolset for building Mac, iPhone, and iPad applications - and with Xcode 4, the tools have been redesigned to be faster, easier to use, and more helpful than ever before. The Xcode IDE understands your project’s every detail, identifies mistakes in both syntax and logic, and will even fix your code for you. Quite simply, Xcode 4 will help you write better code.

Xcode 4 has a brand new user interface, built upon proven technologies that Apple itself uses to build Mac OS X and iOS, and that have produced over a quarter million Mac, iPhone, and iPad apps.

Single Window

As an experienced Xcode user, the first thing you will notice about Xcode 4 is that the many windows used to perform the development tasks you work on every day have been consolidated into a single window. The Xcode 4 work area has several unique UI elements that make it easy to work on many different tasks, even multiple projects, without cluttering your work area. Your editor is always front and center.

Navigators

On the left side is a collection of navigators, including the list of files in your project, sorted symbols, a central search interface, issue tracking, debugging data with compressible stack traces, active and inactive breakpoints, and a persistent collection of logs. The unified navigator UI provides live filtering of content and search results, so you can focus on your current task.

Jump Bar

At the top of every editor pane is a path bar showing the relative location of your current file. Click any location in the path to immediately jump to any other file at that level. This is the Jump Bar, and it is so efficient you may wish to dedicate your entire desktop to source code, quickly jumping from file to file.

Interface Builder - Inside

In Xcode 4, Interface Builder has been completely integrated within the Xcode IDE - there is no separate application.

Selecting an interface file (.nib/.xib) in your project will open the IB editor within Xcode. Opening the right-hand Utility area will show the full complement of interface inspectors, as well as the library of controls and UI objects. Drag a control from the library, and drop onto the canvas, to layout your Mac OS X or iOS application.

The best part: you can drag connections directly from the UI design to the source code. Xcode 4’s new split editor layout makes it easy to wire up your actions and outlets simply by dragging a connection to existing code - one gesture and you’re done. Don’t yet have the code ready to connect? Xcode will create a new outlet or action for you, just drag to an empty space in your source file and Xcode will generate the code.

Assistant

Whether writing code, or designing an interface, no change happens in isolation. Even the smallest edit can have a cascading effect throughout your project. You often need to see more than just your current file; you need to see related documents as well.

With the new Xcode Assistant, the two-pane editor layout in Xcode 4 becomes dramatically more powerful. When you turn on Assistant, the IDE will anticipate which other files you need to see, as you work. Editing a new derived class? The Assistant will show you the code for the class you are inheriting. Writing new implementation code? The Assistant will automatically show you the corresponding header. When designing an interface, the Assistant will show you the appropriate controller, making drag-and-drop code connections extremely simple. Data model designing will bring up the classes that back your models - all automatically.

Completely Supports: C, Objective-C, C++

LLVM Compiler 2.0

The LLVM compiler is the next-generation, open source compiler technology, being used in high-performance projects around the world, and is led by engineers on Apple’s compiler team. With LLVM compiler 2.0, the full compiler stack - from the front end parser, to the back end code optimizer - completely supports C, Objective-C, and C++.

LLVM is fast. It compiles code twice as quickly as GCC, yet produces final applications that also run faster. This is because the compiler was built from the ground up as a set of highly optimized libraries, easy to extend, easy to optimize, and designed for today’s modern chip architectures.

With Xcode 4, the compiler is more than a command-line tool. LLVM is fully integrated into the IDE itself. Syntax highlighting, code completion, and every other index-driven feature is handled by the LLVM parser. If the compiler knows about a symbol, so does the Xcode IDE. C, C++, and Objective-C are all accurately understood at editing time, exactly as they are when building.

Fix-it

By utilizing the embedded LLVM engine, Xcode 4 can do a lot more than code completion and syntax highlighting. The new Fix-it feature alerts you to coding mistakes as you type. Just like a word processor will highlight spelling errors, Xcode 4 will highlight common coding mistakes, without the need to click ‘build’ first.

But why stop at alerting you to problems?

The IDE knows what you did wrong because it understands your code. It understands it so well, Xcode 4 can even fix it for you. A single key-press can correct an assignment to a comparison, or append that missing semicolon.

Fix-it is a great as-you-type companion to the rigorous testing performed by the Build and Analyze feature. The Xcode static analyzer will walk through thousands of potential code paths, looking for places where code, while valid, would behave in unexpected ways, such memory allocation mistakes, never-hit case statements, or improperly constructed loops.

Together, Fix-it and Build and Analyze will find bugs long before your users.

Version Editor

The new Version editor in Xcode 4 makes it easy to see any two versions of your source code, side by side, in a live editor. More importantly, the Version editor is a new way to think of source control management in an IDE, because the comparison view is also a timeline. Drag the slider in the middle and you travel back in time through your project, comparing any two versions.

The Version editor can also show you a detailed log of past events, and track blame for past check-ins. Complex SCM commands are managed for you behind the scenes. It is even possible to manage multiple projects within a single Xcode 4 workspace, one project managed in Subversion, the other in Git, all updated automatically.

3x Faster 2.5x More Efficient

New Debugger

Xcode 4 introduces LLDB, a brand new debugging engine contributed by Apple to the LLVM.org open source project. Like LLVM, the new LLDB engine is designed from the ground up to consume much less memory, and be a rocket when it comes to performance.

The new LLDB debugging engine is the perfect fit for the new Xcode 4 debugging interface. When your app is running, the navigator will show a stack trace you can expand or compress to show or hide stack frames as you debug. As you step through, you can even lock onto a single thread then click “continue” and follow that specific thread of execution. Multicore debugging in Xcode 4 is now as easy as multicore coding with blocks and Grand Central Dispatch.

Instruments for Xcode 4

Instruments has a streamlined interface, complete with the new Jump Bar, and stack compression from Xcode 4‚Äôs UI. Using Xcode4‚Äôs new launch schemes, it is easier than ever to create a robust test harness to run your app in Instruments. That includes launching Instruments in ‚Äúdeferred mode‚Äù, keeping the data collection UI off screen and saving system resources for running and metering your application.

New data collection instruments are also available, including OpenGL ES for tracking iPhone graphics performance, new memory allocation monitoring that can find unintended memory growth, Time Profiler on iOS for collecting samples with very low overhead, and complete System Trace for insight into how all system processes interact.

Instruments covers even more ground, has even lower overhead, and is more useful than ever before.