Swift For Dummies
Book image
Explore Book Buy On Amazon

In the case of a simple Xcode project (such as Locatapp), the structure is very simple: one workspace with one project with one target. If you want to, you can move onto a workspace with multiple projects, each of which has multiple targets. Alternatively, you can opt for a workspace with a single project with multiple targets.

The structures outlined here come into play in any of those scenarios, but you only need to understand what you have in the Xcode template you’re using: one project called Locatapp that contains two targets, Locatapp (the app you’re building) and LocatappTests (a testing app that Xcode automatically creates).

Although right now you’re working with a very simple project, having a basic understanding of the structure of more complex projects right from the start can be very helpful. In particular, you can start thinking about future directions for your project, and knowing the options available to you in Xcode can help you think of a complex app or even a suite of apps.

The figure shows the structure of a Locatapp project. Here are the important points to note about these files and folders (they are discussed from the top down in the figure).

image0.jpg
  • DS_Store: This file is normally hidden (this is why it’s shown in gray). It’s in every folder on OS X, and it contains information about the files in that directory. Developers often use a Terminal command to show hidden files in their folders, but you don’t need to worry about that for the moment.

  • Target folders: The project has two targets by default. One is the actual app (Locatapp) and the second is code to run automated tests (LocatappTests). A tests target is included by default in many of the Xcode templates.

  • Locatapp.xcodeproj: This file is at the top level of the project folder along with the folders for the two targets (Locatapp and LocatappTests). This is the file you open to start work on your project. It is located between the two target folders (Locatapp and LocatappTests) because the files and folders are shown in alphabetical order.

As noted previously, the structure of files within this project folder is set when you create the project. You can modify locations and relationships using the File inspector in the utilities area, but most of the time, you should leave the locations and relationships alone.

If you move things around, Xcode can get confused (as can you). If you must move files around, don’t use the Finder. Most developers prefer not to use the Finder to modify, move, or rename files or folders within a project folder. Use the File inspector or the Edit→Refactor→Rename command to do that.

About This Article

This article is from the book:

About the book author:

Jesse Feiler is a developer, consultant, and author specializing in Apple technologies. He is the creator of Minutes Machine for iPad, the meeting management app, and Saranac River Trail and is heard regularly on WAMC Public Radio for the Northeast’s The Roundtable.

This article can be found in the category: