AddThis Social Bookmark Button

Print
Programming With Cocoa

Build Your First Cocoa App

05/18/2001

Until now, our focus has been the broad concepts of object-oriented programming and how Objective-C implements these concepts in the language. In this article, I want to get you started using the developer tools, with a bit of exposure to Project Builder, but more specifically Interface Builder. We will also create our first Cocoa application, which I think you will find to be quite rich in functionality despite its unique nature -- that is, it requires no coding on your part at all.

The toolbox

Project Builder and Interface Builder are the two developer tools for creating Mac OS X applications. Project Builder is Apple's integrated development environment (IDE) that allows you to edit, compile, and debug your application's source code. In addition to building the code, Project Builder helps you manage all the files that your application relies on.

Interface Builder, on the other hand, provides a set of tools that allow you to create a fully functional GUI in the true spirit of Macintosh by purely graphical means.

Rather than giving you a lengthy description of the developer tools, I want to present them to you as we create our application. So let's get started.

Project Builder

Apple's Project Builder IDE is akin to Codewarrior or to Microsoft's Visual Studio. It combines a source-code text editor, a front-end to the Objective-C compiler, and GNU debugger into an integrated interface for coding. Furthermore, Project Builder helps you organize and manage all the source files, frameworks, configuration files, and resources associated with your application. This collection of files is known as a "project."

Comment on this articleNow that you've built a Cocoa app, do you have any observations to share with your fellow coders?
Post your comments

Included with Project Builder are several project templates for many standard types of applications and programs that range from device drivers and kernel extensions, to Cocoa, Carbon, and Java applications. Templates provide a skeletal set of files and resources common to all applications associated with the template. Additionally, any compilation and general configuration options are preset for the application. The type of application and project we're going to create today is a Cocoa document-based application.

Project Builder is found in the folder /Developer/Applications. Once you have it started, we want to create a new project. Do this by selecting New Project from the File menu. Project Builder presents you with a list of all the possible project types; select Cocoa document-based application. Click Next. In the next screen you will be asked for a name to give your project and a place to keep it. You can put it wherever you like, but let's call it SimpleTextEditor. Click Finish, and the new project window will come up.

Screen shot of the new project window.
The project window.

The project window has several elements. The pane on the left edge of the window is a list of folders (called "groups" by Project Builder because they do not represent real folders in the file system) that contain and organize all the various project files and resources. This is merely an organizational convenience, and since the groups do not reflect the organization of files in the file system, you are free to rearrange them to your heart's content without fear of Project Builder losing track of anything.

Pages: 1, 2, 3, 4

Next Pagearrow