Introduction: Build an Application in Xcode 2 on a Mac

About: I like macs particularly mac OS X 10.4.11 (Latest Version Of Tiger). I have also worked with Ubuntu 9.10 (Karmic Koala) and Ubuntu 10.04 (Lucid Lynx) which was released in April 2010, and have worked with Wind…

Hello! This is MacWorldWizardz here again today to show you how to build an application (fully functional) in Xcode on a Mac! This is quite simple based on the type of application you wish to build, compile, and make.

Now, all you need is:

- Xcode 2 (Normally on OS X Tiger)
- A PPC Macintosh or Intel (either is mighty fine)!
- A Copy of OS X Tiger or Lower. (Already Installed with Xcode or On Disc)
- A Keyboard
- A Mouse
- WebObjects (It's okay if you don't know what this is)!
-  X11 (on OS X DVD)

If you don't have these already installed on your Macintosh, Copies of Tiger and anything below that should have the "Extras" Package on the disk with OS X. If Xcode is not installed, insert the OS X Install DVD and navigate to the "Extras" Package. Double-Click it and follow the on-screen Instructions to Install it. Go ahead and Install X11 and the "Xcode" Package if there is one in there.

Now, I recommend that you do exactly as I do on this Instructable until you learn the basics.

Step 1: Navigating and Opening Xcode

Alright, now that you have Xcode Installed (or already had it installed), it's time to open the Xcode Application.

There are multiple ways to open Xcode. You can:

- Navigate to it in Finder.
- Locate it in Spotlight.
- Or open it from the dock.

But, here's how we are going to do it!

At the top right of the screen, click the Blue Spotlight Button. Then type "Xcode" and then hit the enter key. Once you've done that, double-click the Xcode "Application". I have included some pictures of the Spotlight. Be sure the "Xcode" Application has shown up in the dock. If you click on it, it will not show any sign of it being open, execpt that the menu-bar will switch to Xcode. Look at the picture below for an example.

By the way, there is a "Developer" folder in the ROOT of your Macintosh Hard-Drive. Double-Click that Folder and you will have access to Developer applications, including, Xcode, located at:  Your Hard Drive < Developer < Applications < Xcode. This is NOT on Leopard or Snow Leopard. :-)

Step 2: Starting a New Xcode Project.

Alright, now that I have shown you how to open Xcode, we are going to open a New Project.

We do this by clicking "File" on the Menu-Bar, and clicking "New Project".

"Please note that I am using Xcode 2, and that this tutorial will not work for you unless you are using Xcode 2. To find out what version you are using, click "Xcode" in the Menu-Bar and click "About Xcode". Look at the picture below for an example, and what you "About Xcode" window should look close to."

Once you have clicked "New Project", scroll down and click "Cocoa Application" and click "Next".

After that, You are going to need to name the application. Name it, the click "Next" again. Then, it will take you to the Xcode window.

Step 3: Opening Up the Application's Main Window for Editing

Once you have completed the last step, it will bring you to Xcode's Main Menu. There are a bunch of buttons here and we want to be careful not to mess with any of them, because it can mess up your application. Here are some main things you need to know.

In the Xcode Main Menu:

- Main.nib is the application's main menu (the window).
- Info.plist and InfoPlist.strings are have to do with the "About Panel" in your Application. We will edit these later.
- To Build (or "Make") your Application, all you have to do is click "Build". It may ask you to save the windows or other edited things.
- The "Build and Go" button is to "Make" the Application and Open the .app (Application) file. We don't want to use this because sometimes it may incorrectly target another file, confusing some people.
- All of the other stuff there, please don't mess with it, unless you know what you're doing.

Everything else in the main menu, we are not going to mess with. Don't click any boxes or anything that has to do with anything other than the list above.

Click "Build", which, as stated, will build the application. We want to do this so it builds the application and allows us to edit it. Then, double-click "Menu.nib". This will open an application called "Interface Builder", which is included with Xcode. This, we will use to build the main window.

Step 4: Customizing the Main Window - a Tour Around!

Now, this is the LONGEST STEP. Take a deep breath and relax for a minute. You may be here up to half an hour, or even an hour depending on what application you build. So, if you are frustrated or tired, or anything like that, you need to relax before you go further. If you don't, you can easily get frustrated. I have included my application that was made in Xcode for Inspiration.

Now, I am going to explain all of this (Interface Builder) to you. If you are a slow reader or if you don't want to read all of this, since you are on a mac, I know that they put in Speech Support. Navigate to System Prefrences and choose a voice. Then, open this up in Safari, Highlight all of this text, right click it, and navigate to Speech, Start Speaking. It will read it to you. :-)

What everything does...

- Cocoa Controls Window has buttons and things for the main window. We are not going to use any browsers (NSBrowsers) or WebViews on there.

-  The Menu.nib window is where you can add a TYPE OF FUNCTION to the button, Inspector connects the SPECIFIC Function. (We will get to this in a minute). This window is also the window where you can open up things like Windows, and Panels, and the Menu-Bar for editing. Click on the tabs and you will find different things. From here, you CAN'T drag the items to the windows or panels, and the "Classes" tab is advanced, so don't pay attention to it.

- The Main Window (Window), or other Panels.. is the application's windows or panels. This is where you drag buttons and things to. What the panel or window looks like here, is what it will look like in the REAL Application.

- The Inspector is where change features of the window, panes, buttons, or anything like that. You can change anything up a bit from here, however, we will not touch the "AppleScript" feature or the "Sherlock" feature from the drop-down menu. To change the functions of the button or window, click the drop-down menu. "Connections" is where you change the ACTION of the button (for buttons, text fields or etc), "Attributes" is where you change the button or window's features and ease of use. Such as the text field option to be "Editable" in the REAL application.


To connect a button and an action, hold down the APPLE KEY OR THAT SWIRLY KEY and drag it over to the "Menu.nib" window. First Responder is really for TEXT FIELDS (Such as Undo, Redo, Cut, Paste). File's Owner is for.. window based actions (Hide other Applications, etc). If you had a panel or window of some sorts and wanted to connect and button in THE MAIN WINDOW to the Panel (For example, to open the Panel and close it) you would do the same connecting process, execpt you drag the little line to "Panel or Window 2" ect. Some functions are different and if you look at one of the Images below, I have a picture of actions with notes explaining what they do. PLEASE look at the Images before you start building. Feel free to experiment around.

If you look at the Images below, I have added extra notes.

Step 5: Changing the Application's "About" Box.

Now that you are ready to change the about panel, you are almost done!

Go back into Xcode and Double-Click Info.Plist. Change all of the numbers in the document to your desired version.

And then, go to InfoPlist.Strings and Change what you see (obvious) to what you desire to be on there! Then, just save using the save option in the menu-bar! That's it!

Step 6: Building and Saving the Application.

Once you have completed your application, head over to Xcode and click "Build". It may ask you to save the Menu.nib or other changed files. This is okay. Click "Save All".

Now look at the bottom right of the Xcode Window. If you didn't change anything other than what we've discussed and everything went right, it should say "Success" (See Picture). If it doesn't, you messed with something that I may have said not to.

Also, be sure to test the application before you get done.

Step 7: Making Copies, Finalizing.

Go ahead and make a copy of the application. You may also want to put the application in a DMG File that you can make from Disk Utility, like the other guys. Be sure to type up a instruction guide for the application! That's It! Your Done!