Читать книгу Swift iOS 24-Hour Trainer - Mishra Abhishek - Страница 8

Section I
Hello iOS!
Lesson 2
A Tour of Xcode and the iOS Simulator
An Overview of the Xcode IDE

Оглавление

The Xcode IDE features a single window, called the workspace window (Figure 2.4), where you get most of your work done.


Figure 2.4


The Navigator Area

The left side of the workspace window is the navigator area (Figure 2.5).


Figure 2.5


The navigator area consists of eight tabs; each of these tabs (called navigators) shows different aspects of the same project. You can switch between navigators using the navigator selector bar at the top of the navigator area (Figure 2.6).


Figure 2.6


The Project Navigator

The project navigator (Figure 2.7) shows the contents of your project. Individual files are organized within groups that are represented as folders in a tree structure. The top-level node of this tree structure represents the project itself. These groups are purely logical and provide a convenient way to organize the contents of your project. A group may not necessarily correspond to actual folders on your hard drive.


Figure 2.7


When a new project is created, Xcode will create two groups (folders) under the project node. Figure 2.7 shows what the project navigator would look like if you were to create a new project using the Single View Application template called HelloWorld without unit tests or user interface tests.

As you can see, the top-level node is called HelloWorld, and the two groups below that node are:

HelloWorld: Contains the source code for your application.

Products: Contains the finished products, created after the source code compiles successfully.

In most cases, you will work with a single project at a time in the Xcode workspace window; however, it is possible to open multiple projects in the project navigator using a workspace file. A workspace file has the file extension .xcworkspace and contains references to one or more project files. You will not be creating workspaces in this book; however, if you were to open a workspace file, the workspace window would display information on multiple projects contained within the workspace (Figure 2.8).


Figure 2.8


To create a new group, right-click an existing node in the project navigator and select New Group from the context menu. You can move files between groups by using simple drag-and-drop operations in the project navigator. If the groups in the project navigator correspond to actual folders on your Mac, then moving things around in the project navigator will not move the corresponding files into new locations on your Mac.

To delete a file, simply select the item and hit the backspace key on your keyboard. Xcode then asks you if you intended to delete the actual file from your Mac or just remove the reference from the project. The process of deleting a group is similar to that of a file; keep in mind that deleting a group deletes any files within that group.

At the bottom of the project navigator is a set of icons. You can use these icons to filter what is displayed in the project navigator based on certain criteria.

NOTE

Note To learn more about the project navigator, read the Project Navigator Help document at http://developer.apple.com/library/ios/#recipes/xcode_help-structure_navigator/_index.html.

The Symbol Navigator

The symbol navigator (Figure 2.9) shows the classes in your project along with their methods and member variables. A top-level node in a tree-like structure represents each class. Expanding the class node reveals all its member variables and methods.


Figure 2.9


The Find Navigator

The find navigator (Figure 2.10) lets you find all occurrences of some text, across all files of the project.


Figure 2.10


A root-level node in a tree represents each file that has one or more occurrences of matching text. Expanding the node reveals the exact positions within that file where these matches were made.

The Issue Navigator

The issue navigator (Figure 2.11) lists all compile-time errors and warnings in your project. While compiling a file, Xcode raises an issue each time it finds a problem with the file. Severe show-stopping issues are flagged as errors, whereas less severe issues are flagged as warnings.


Figure 2.11


Each file with one or more errors/warnings is represented by a root-level node in a tree-like structure. Expanding the node reveals the exact positions within that file where these errors/warnings were encountered.

The Test Navigator

The test navigator (Figure 2.12) gives you a snapshot of all the unit tests created with the project. A root-level node in a tree-like structure represents each test suite. Expanding this node reveals the test fixtures within that test suite. Clicking a test fixture (method) will open the corresponding code in the editor area. To run a test, you could click the play icon to the right of the test fixture.


Figure 2.12


The Debug Navigator

The debug navigator is used during an active debugging session and lists the call stack for each running thread. Debugging is an advanced topic and is not covered in this book.

The Breakpoint Navigator

The breakpoint navigator lists all breakpoints in your code and allows you to manage them. A breakpoint is an intentional pause-point that you can set in your project. When the app is being executed, Xcode interrupts the execution of the application when it encounters one of these pause-points and transfers control to the debugger. This is extremely useful when trying to figure out why a particular piece of code does not work and you want to inspect the values of variables and content of memory. Breakpoints and the debugger work only when the application is being executed in debug mode. Breakpoints and debugging are advanced topics, and are not covered in this book.

The Report Navigator

The report navigator shows you a history of build logs and console debug sessions. Building is the complete process of creating an executable application from your source code files. Compilation is a part of the build process. Each time you build a new executable, Xcode creates a build log that contains, among other things, a list of files that were compiled.

The Editor Area

The right side of the workspace window is the editor area (Figure 2.13). Xcode includes editors for many file types, including source code, user interface files, XML files, and project settings, to name a few.


Figure 2.13


The content of the editor area depends on the current selection in the navigator area. When you select a file in the navigator area, Xcode tries to find an appropriate editor for that file type. If it can't find one, it opens the file using Quick Look (which is also used by the Finder).

Jump Bars

At the top of the editor area is the jump bar (Figure 2.14). The jump bar displays the path to the current file being edited and can be used to quickly select another file in the workspace. The jump bar also has back and forward buttons to move through a history of files edited. Each element in the path displayed in the jump bar is a pop-up menu (Figure 2.15) that you can use to navigate around your project.


Figure 2.14


Figure 2.15


The contents of the jump bar depend on the type of file you're viewing. When editing a user interface file, for example, the jump bar enables you to navigate to individual interface elements.

The Source Editor

When you select a source-code file in the navigator area, or a text/XML file, Xcode uses the source editor to open the file. This is the editor with which you will spend most of your time when you write your code. The source editor has several helpful features, such as syntax highlighting and code completion hints. You can configure individual features of the source editor using Xcode preferences.

The Assistant Editor

The assistant editor (Figure 2.16) was introduced in Xcode 4 and enables you to view multiple files side-by-side.


Figure 2.16


The assistant editor is not visible by default and can be accessed by using the editor selector buttons in the Xcode toolbar or by selecting View Assistant Editor Show Assistant Editor. Option-clicking a file in the project navigator or symbol navigator opens it in the assistant editor. You can create additional assistant editor panes by using the + button in the jump bar of the assistant editor.

The Version Editor

If your project is under version control, you can use the version editor to compare the current version of a file with a previous version. Like the assistant editor, the version editor is not visible by default and can be accessed by using the editor selector buttons in the Xcode toolbar. Version control is not covered in this book.

The Utilities Area

The utilities area (Figure 2.17) supplements the editor area. You can display it by selecting View Utilities Show Utilities or by clicking the utility button in the toolbar.


Figure 2.17


The Inspector Area

The top portion of the utilities area contains the inspector area (Figure 2.18). Like the navigator area, the inspector area also contains multiple tabs that can be switched using a selector bar at the top of the window.


Figure 2.18


The number of tabs available depends on the currently selected item in the project navigator. Regardless of what is selected in the project navigator, the first two tabs are always the file inspector and the quick help inspector. The file inspector provides access to the properties of the current file. The quick help inspector provides a short description of the current file.

The Library Area

The bottom portion of the utilities area contains the library area (Figure 2.19). This area contains a library of file templates, user interface objects, and code snippets that you can use in your applications.


Figure 2.19


The library area also provides a convenient method to access all the media files in your project. A selector bar at the top of the library area provides access to four different library categories.

The Debugger Area

The debugger area (Figure 2.20) also supplements the editor area. You can access it by selecting View Show Debug Area or by clicking the debugger button in the toolbar.


Figure 2.20


The debugger area is used while debugging an application and to access the debug console window. You can use this area to examine the values of variables in your programs.

The Toolbar

The Xcode toolbar (Figure 2.21) is located at the top of the workspace window. Use the first two buttons on the left side to run/stop the active build scheme. Immediately following the stop button is the Scheme/Target multi-selector. When you create an iOS project, Xcode creates a scheme with the same name as the project and several build targets.


Figure 2.21


The build targets that are typically generated for a project include:

• iOS Device

• iPad 2 (if it is an iPad or Universal project)

• iPad Air (if it is an iPad or Universal project)

• iPad Retina (if it is an iPad or Universal project)

• iPhone 4S (if it is an iPhone or Universal project)

• iPhone 5 (if it is an iPhone or Universal project)

• iPhone 5S (if it is an iPhone or Universal project)

• iPhone 6 Plus (if it is an iPhone or Universal project)

• iPhone 6 (if it is an iPhone or Universal project)

You can use the Scheme/Target multi-selector to switch build targets and create/edit schemes. Managing schemes is an advanced topic beyond the scope of this book.

To the right of the Scheme/Target multi-selector is a status window. Following the status window, the toolbar contains the editor selector and utility selector buttons, which have been covered in the previous sections.

Swift iOS 24-Hour Trainer

Подняться наверх