Home / iPad

Exploring Your Project

It turns out that you do most of your work on projects using a Project window. If you have a nice, large monitor, expand the Project window so you can see everything in it as big as life. This is, in effect, Command Central for developing your iPad app; it displays and organizes your source files and the other resources needed to build your app.

You have control over Command Central - you can organize your source files and resources as you see fit. The Groups & Files list on the left is an outline view of all of your project's files - source code, frameworks, and graphics, as well as some settings files. You can move files and folders around and add new folders.

You may notice that some of the items in the Groups & Files list are folders, whereas others are just icons. Most items have a little triangle (the disclosure triangle) next to them. Clicking the little triangle to the left of a folder/icon expands the folder/icon to show what's in it. Click the triangle again to hide what it contains.

To see more of the code that's already provided with the View-based Application template, select Classes in the Groups & Files list on the left side of the Project window. The first file should already be selected in the Detail view of the Project window: DeepThoughtsAppDelegate.h. (Actually, you can select any file in the Detail view to see code.) The code appears in the Editor view.

Here's a summary of what you see:

  • The Groups & Files list: As described earlier, the Groups & Files list provides an outline view of everything in your project. If you select an item in the Groups & Files list, the contents of the item are displayed in the topmost-pane to the right - otherwise known as the Detail view.
  • The Detail view: Here you get detailed information about the item you selected in the Groups & Files list.
  • The Toolbar: Here you can find quick access to the most common Xcode commands. You can customize the toolbar to your heart's content by right-clicking it and choosing Customize Toolbar from the contextual menu that appears. You can also choose View → Customize Toolbar.
    • The Overview menu lets you specify the active SDK and active configuration, which I describe in "Building and Running Your Application" in this tutorial.
    • The Action menu lets you perform common operations on the currently selected item in the Project window. The actions change depending on what you've selected. (The same actions are available in the context-sensitive shortcut menu that appears when you Control-click a selected item.)
    • Pressing the Build and Run button compiles, links, and launches your app in the Simulator.
    • The Breakpoints button turns breakpoints on and off and toggles the Build and Run button to Build and Debug.
    • The Tasks button allows you to stop the execution of the app that you've built.
    • The Info button opens a window that displays information and settings for your project.
    • The Search field lets you search the items currently displayed in the Detail view.
    • The Show/Hide Toolbar button shows or hides the entire Toolbar.
  • The status bar: Look here for messages about your project. For example, when you're building your project, Xcode updates the status bar to show where you are in the process - and whether or not the process completed successfully.
  • The favorites bar: The favorites bar appears under the Toolbar and works like other favorites bars - you can bookmark places in your project. This bar isn't displayed by default; to put it onscreen, choose View → Layout → Show Favorites Bar from the main menu.
  • The Text Editor navigation bar: This navigation bar contains a number of shortcuts (I explain more about them as you use them):
    • Bookmarks menu: You create a bookmark by choosing Edit → Add to Bookmarks.
    • reakpoints menu: Lists the breakpoints in the current file.
    • Class Hierarchy menu: The superclass of this class, the superclass of that superclass (if any), and so on. In Objective-C, you can base a new class definition on a class already defined, so that the new class inherits the methods of the base class it is based on. The base class is called a superclass; the new class is its subclass, and the hierarchy defines the relationship between a superclass, its subclass, and subclasses of the subclass (and so on).
    • Included Files menu: Lists both the files included by the current file, as well as the files that include the current file.
    • Counterpart button: Due to the natural split in the definition of an Objective-C class into interface and implementation, a class's code is often split into two files. The Counterpart button allows you to switch between the header (or interface) file, such as DeepThoughtsAppDelegate.h, and the implementation file, such as DeepThoughtsAppDelegate.m. The header files define the class's interface by specifying the class declaration (and what it inherits from), instance variables (a variable defined in a class - at runtime all objects have their own copy), and methods. The implementation file, on the other hand, contains the code for each method.
    • Lock button: Indicates whether the selected file is unlocked for editing or locked (preventing changes). If it's locked, you can click the button to unlock the file (if you have permission).
  • The Editor view: Displays a file you've selected, in either the Groups & Files list or Detail view. You can also edit your files here - after all, that's what you'd expect from the Editor view - although some folks prefer to double-click a file in the Groups & Files list or Detail view to open the file in a separate window.
    If you have any questions about what something does, just position the mouse pointer above the icon, and a tooltip explains it.
  • Classes is the group in which Xcode places all the template code for DeepThoughts, and you should also place new classes you create in the Classes group, although you aren't obliged to. The Classes group has four distinct source-code files:
    • DeepThoughtsAppDelegate.h
    • DeepThoughtsAppDelegate.m
    • DeepThoughtsViewController.h
    • DeepThoughtsViewController.m
  • Other Sources is the group in which you typically would find the frameworks you're using - stuff like DeepThoughts_Prefix.pch as well as main.m, your application's main function.
  • The Resources group contains, well, resources specifically for the target (in this case, an iPad), such as .xib files (which you find out about in "Using Interface Builder" in this tutorial), property lists, images, other media files, and even some data files.
    Whenever you choose the View-based Application template and name it DeepThoughts, Xcode creates the following files for you:
    • DeepThoughts-Info.plist
    • DeepThoughtsViewController.xib
    • MainWindow.xib
  • Frameworks are code libraries that act a lot like prefab building blocks for your code edifice. By choosing the View-based Application template, you let Xcode know that it should add UIKit framework, Foundation.framework, and CoreGraphics.framework to your project, because it expects that you'll need them in an app based on the View-based Application template.
  • The Products group is a bit different from the previous three items in this list: It's not a source for your app, but rather the compiled app itself. In it, you find DeepThoughts.app. At the moment, this file is listed in red because the file can't be found (which makes sense because you haven't built the app yet).
    A file's name appearing in red lets you know that Xcode can't find the underlying physical file.

If you happen to open the DeepThoughts folder on your Mac, you won't see the "folders" that appear in the Xcode window. That's because those folders are simply groupings that help organize and find what you're looking for; this list of files can grow to be pretty large, even in a moderate-size project.

When you have a lot of files, you'll have better luck finding things if you create subgroups within the Classes and/or Resources groups, or even whole new groups. You create subgroups (or even new groups) in the Groups & Files list by choosing New Project → New Group. You then can select a file and drag it to a new group or subgroup.

[Previous] [Contents] [Next]