XCode5 review

Along with the release of iOS 7 for its mobile devices, Apple also introduced a major upgrade to its Xcode suite of development tools. Xcode, now in Version 5, consists of a compiler, a linker, a source-code-level debugger, a code analyzer, performance measurement instruments, a simulator, and other utilities, all managed by an IDE. The improvements in the Xcode 5 release should allow you to write better applications for iOS and OS X that are faster and have fewer bugs.

What in Xcode was changed to achieve these goals? Looking at the UI, you can see some minor tweaks (such as a smaller toolbar to give more screen real estate to the editor), but these modifications aren’t as radical as the UI makeover Xcode saw with the Version 4 release. The major changes in Xcode 5 were made under the hood.

[ Also on InfoWorld: New in iOS 7: What developers need to know | How iOS 7’s new APIs change the game for business | Keep up with key Apple technologies with the Technology: Apple newsletter. ]

Building it faster
Before diving into the details, it’s worth noting that the last vestiges of the GNU toolset, such as the GNU Compiler Collection and linker, have been swept away. Going forward, the only way to write and debug code for iOS or OS X is with Apple’s LLVM compiler and LLDB debugger.

In addition, for OS X apps Garbage Collection (GC) is deprecated. You should use Automatic Reference Counting (ARC), a memory management scheme already in use on iOS. ARC produces more predictable patterns of code execution and memory use. In fact, Xcode itself was formerly a GC app, but with this release, it now uses ARC. The result is that many common Xcode operations, such as search, nib files compilation, and incremental builds are now twice as fast as in Xcode 4.

The IDE uses a new modules mechanism to accelerate code compilation and linking. Modules are similar to precompiled header files in that the plethora of API calls, class properties, and constants found in the lengthy header files are distilled down to symbolic references and information. However, in Xcode 5 this information is stored in an optimized and searchable symbols database. Now when the compiler encounters a symbolic reference, it can do a highly efficient database search for just the information required.

This is all done transparently; you don’t have to change any of your code. With modules, Apple has seen improvements in build times that range from a few percent up to 40 percent faster, depending upon how well you managed your program’s precompiled headers. Unfortunately, module support isn’t available for C++ programs or private frameworks.

The compiler can parse comments made in Doxygen or HeaderDoc about method parameters and integrate this information into the documentation system. Xcode can even compare the function arguments in the code versus those in the comments and flag mismatches in the parameter names for you. This lets you fix both the code and the documentation as they evolve.

One time-consuming phase of app development is getting the UI to look right, especially for the different screen sizes of iOS devices. You can arrange UI elements with Interface Builder (IB), and set various constraints on where the elements land. Or you can allow IB to automatically place elements, but its results have been less than stellar.