After the Xcode application downloads, you will find it in your Applications folder. Open the Xcode application, by double-clicking it, using Launchpad, or however you like to launch apps. I recommend adding Xcode to your Dockfor easy access.
Xcode will present a licensing agreement (see Figure 1-3), which you are encouraged to at least skim over, but must agree to before proceeding.
Figure 1-3. License Agreement
Once you’ve gotten through all of the preliminaries, you’ll see Xcode’s startup window, as shown in Figure 1-4.
Figure 1-4. Xcode’s Startup Window
The startup window has several self-explanatory buttons to help you get started. It also lists the projects you’ve recently opened.
The interesting parts of Xcode don’t reveal themselves unless you have a project open, so start by creating a new project. Click on the Create a new Xcode project button in the startup window
(or choose File ➤ New ➤ Project . . . from the menu). The first thing Xcode will want to know is what
kind of project you want to create, as shown in Figure 1-5.
Figure 1-5. Project Template Browser
The template browser lets you select a project template. Each template creates a new project
pre-configured to build something specific (application, library, plug-in, and so on) for a particular platform (iOS or OS X). While it’s possible to manually configure any project to produce whatever you want, it’s both technical andtedious; save yourself a lot of work and try to choose a template that’s as close to the final “shape” of your app as you can.
In this book, you’ll only be creating iOS apps, so choose the Application category under the iOS section—but feel free to check out some of the other sections. As you can see, Xcode is useful for much more than just iOSdevelopment.
With the Application section selected, click the Single View Application template, and then click
on the Next button. In the next screen, Xcode wants some details about your new project, as shown in Figure 1-6. What options you see here will vary depending on what template you chose.
Figure 1-6. New project options
For this little demonstration, give your new project a name in the Product Name field. It can be anything you want—I used MyFirstApp for this example—but I recommend you keep the name simple. The OrganizationName is optional, but I suggest you fill in your name (or the company you’re working for, if you’re going to be developing apps for them).
The Company Identifier and Product Name, together, create a Bundle Identifier that uniquely identifies your app. The Company Identifier is a reverse domain name, which you (or your company) should own. It isn’t important rightnow, as you’ll only be building this app for yourself, so use any domain name you like. When you build apps that you plan to distribute through the App Store, these values will have to be legitimate.
The rest of the options don’t matter for this demonstration, so click the Next button. The last thing Xcode will ask is where to store your new project (see Figure 1-7). Every project creates a project folder, named after your project. All of the documents used to create your app will be stored in that project folder. You can put your project folder anywhere (even on the Desktop). In this example, I’m creating a new iOS Development folder so that I cankeep all of my project folders together.
Figure 1-7. Creating a new project
Welcome To Xcode
With all of the details about your new project answered, click the Create button. Xcode will create your project and open it in a workspace window. An exploded view of a workspace window is shown in Figure 1-8. This is wherethe magic happens, and where you’ll be spending most of your time in this book.
Figure 1-8. Xcode workspace window
A workspace window has five main parts:
n Navigator area (left)
n Editor area (center)
n Utility area (right)
n Debug area (bottom)
n Toolbar (top)
You can selectively hide everything except the editor area, so you may not see all of these parts.
Let’s take a brief tour of each one, so you’ll know your way around.
Navigation Area
The navigators live on the left side of your workspace window. There are eight navigators: Project
Symbol Find Issue Test Debug
Breakpoint Log
Switch navigators by clicking on the icons at the top of the pane, or from the View ➤ Navigator
submenu. You can hide the navigators using the View ➤ Navigator ➤ Hide Navigator command
(Command+0) or by clicking the left side of the View button in the toolbar (see Figure 1-9). This will give you a little extra screen space for the editor.
Figure 1-9. Navigator view controls
The project navigator (see Figure 1-8) is your home base, and the one you’ll use the most. Every source file that’s part of your project is organized in the project navigator, and it’s how you select a file to edit.
The symbol navigator keeps a running list of the symbols you’ve defined in your project. The search navigator will find text in multiple files. The issues, debug, breakpoint, and log navigators come into play when you’re ready tobuild and test your app.
Editor Area
The editor area is where you create your app—literally. Select a source file in the project navigator, and it will appear in the editor area. What the editor looks like will depend on what kind of file it is.
What you’ll be editing the most are program source files, which you edit like any text file (see Figure 1-8), and Interface Builder files, which appear as graphs of objects (see Figure 1-11) that you connect and configure.
The editor area has three modes: Standard editor Assistant editor
Version editor
The standard editor edits the selected file. The assistant editor splits the editor area and (typically) loads a counterpart file on the right side. For example, when editing an Objective-C source file,
as shown in Figure 1-10, the assistant automatically loads its counterpart file—the header file that contains the definitions for that file—on the right. When editing Interface Builder files, it may display the Objective-C source filefor the object that’s being edited, and so on.
Figure 1-10. The assistant editor
The version editor is used to compare a source file with an earlier version. Xcode supports several version control systems. You can “check-in” or take a “snapshot” of your project, and later compare what you’ve written against an earlier version of the same file. We won’t get into version control in this book. If you’re interested, read the section Save and Revert Changes to Projects in the Xcode Users Guide.
To change editor modes, click the Editor control in the toolbar or use the commands in the View menu. You can’t hide the editor area.








No comments:
Post a Comment