If you are used to developing with Visual Studio or Eclipse, all the necessary features / dev-tools are available from one user interface. With Visual Studio, more features are available with higher editions.
With Mac / iPhone development, the situation is slightly different. The tools are a little bit spread out and come with different names. However, they all work collectively to build the application. If you were to refer them by one brand name, they are called Xcode Tools. And, all these applications / development tools are installed when you install the iPhone SDK.
You would need to work with at least the following two tools to develop applications for iPhone:
- Xcode - for coding
- Interface Builder - for developing user interfaces
In addition to the above two, you would use a tool called Instruments to do the performance analysis on the application you developed.
Then there is the Dashcode, which can be used for developing web applications on iPhone. And finally, there is the iPhone Simulator which assists a great deal in developing applications for iPhone. You can test your applications more conveniently with the iPhone Simulator, before testing them with the iPhone device.
Figure 1. The relationship between Xcode, GDB, Interface Builder, Instruments, and iPhone Simulator. These are the main tools for developing NATIVE iPhone applications. Dashcode is used for developing WEB applications.
The central tool in Xcode toolset is Xcode. This tool provides a way to:
- Create and Manage Projects
- Write code via Source Code Editor
- Compile and Run applications
- Debug applications (GDB is used under the covers)
- Be the front-end for Source Code Management (SCM) system
- Launch Interface Builder for creating user interface
- Launch Instruments for the performance analysis
Figure 2. Xcode with Metronome project open. This is the central tool in the development toolset for iPhone, iPod Touch, and Mac OS X applications. All the project related files can be seen in the left navigator.
As you can see, Xcode lets you manage and develop the files related to the iPhone project. You have the usual source code files, with extensions .h (header) and .m (implementation). You have the files with extensions .framework and .dylib, which are the frameworks and dynamic libraries. Then you have the .xib and .nib files, which represent the user interfaces of the applications. These files are created and updated with Interface Builder.
From the Groups & Files section, you can see the source control (SCM), the project symbols that provide information about variables during debugging, what executables are constructed out of the source, etc.
GDB (GNU Debugger)
GDB is the open source debugger that supports a whole bunch of languages, including C, C++, Objective-C, and Java. Xcode provides the GDB capabilities from a graphical user interface or from a raw command line console where GDB commands can be executed.
Figure 3. The debugging functionality from Xcode, via a GUI window. This window is probably most helpful during most of the debugging. You can see the callstack, variable information, and source in the same window.
Figure 4. The debugging functionality from the GDB console. This window provides all the raw power of GDB. A large set of commands can be used to find out information about variables/objects, breakpoints, call stack, etc.
The Interface Builder is used to graphically develop (“draw”) the user interface of an application. These files have the extension .xib (which roughly stands for XML - Interface Builder). These are the textual XML files. These files become .nib files (binary - roughly stands for NextStep - Interface Builder) after compilation and are included in the .app file of the application.
You can open these user interface files in the Interface Builder by double-clicking them in the Xcode project window. New user interface files can be created from the File-New menu of the Interface Builder.
Figure 5. The Interface Builder is shown with the Document Window, the View, the Attribute Inspector, and the Library (or the Toolbox). Here the user interface is a Table View, a commonly used view.
You can perform memory analysis, leak detection, and other performance analysis tasks with a tool called Instruments. This can be run directly from Xcode (from Run - Start with Performance Tool menu item).
Figure 6. Looking at the Object allocation and Leaks from Instruments.
Instruments tool is based on the DTrace toolkit that is part of the OpenSolaris. The “D” in DTrace stands for Dynamic, meaning DTrace provides the Dynamic Tracing functionality.
You can test the applications you developed for iPhone right on the Mac, before transferring them over to an actual iPhone device. You can use the iPhone Simulator to test the applications developed for native iPhone OS, using Xcode. You can also use iPhone Simulator to test the web applications developed using Dashcode.
Figure 8. A utility web application with Dashcode - shown in the iPhone Simulator. This does not require the iPhone SDK.
Figure 9. An application built from Xcode running inside iPhone Simulator. This application is native to iPhone OS and is built with iPhone SDK. This is NOT run inside the Safari web browser (though Internet functionality can be added to native iPhone applications)
The above program is the Metronome sample, which uses the iPhone SDK. The graphics functionality comes from the CoreGraphics/QuartzCore frameworks and the audio functionality comes from the AudioToolbox framework.