Mishra Abhishek

Swift iOS 24-Hour Trainer


Скачать книгу

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).

Screenshot of Xcode IDE Project Navigator with three groups, each labeled marked as Project 1, Project 2, and Project 3 respectively.

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.

Screenshot of Xcode IDE Symbol Navigator with the menus Hierarchial and Flat. Hierarchial is highlighted.

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.

Screenshot of Xcode IDE Find Navigator, with the text delegate in the search bar and search results.

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.

Screenshot of Xcode IDE Issue Navigator with the menus By File and By Type. By File is highlighted.

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.

Screenshot of Xcode IDE Test Navigator.

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.

Screenshot of Xcode IDE Editor Area.

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.

Screenshot of Xcode IDE Jump Bar.

Figure 2.14

Screenshot of Xcode IDE Jump Bar with drop down menu from the element AppDelegate.swift.

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