This chapter provides a gentle introduction to Xcode Source Management, which includes Xcode SCM and Xcode Snapshots. It describes source control concepts you need to know in order to perform source control operations using Xcode successfully. This chapter also compares Xcode SCM with Xcode Snapshots, a multifile undo/redo mechanism.
Source Control Essentials
Xcode Snapshots
Managing Source in Xcode
Source control , which is also known as Source Control Management (SCM) or version control, is a set of tools and procedures developers use to safeguard and manage files and changes made to them over time. By freeing developers from these repetitive and error-prone tasks, source control systems allow developers to concentrate solely on writing and testing code.
A source control system has three major parts: A repository, a client and a server. The repository is a directory tree or database that contains the files managed by a source control system. The files stored in the repository are called managed files. Repositories can reside anywhere but are usually placed in a computer overseen by a system administrator who grants access to the repository and safeguards its contents through regular backups.
The client is the program developers use to interact with the repository. The server is the process that actually modifies the repository. When a developer issues a command to the client, the client talks to the server process to carry it out.
Every developer authorized to access the repository can copy files from the repository into a directory known as the working copy. This is where they make changes to the project. Developers normally don’t have access to each other’s working copies. This feature provides privacy and security because developers are unaware of what their peers are doing until they commit (publish) their changes to the repository.
When a developer submits changes to a file in the repository, the source control system increments its revision number (also known as version number). Under this scheme, the history of each file is recorded as a set of revisions, which developers can retrieve and compare individually.
Source control provides several benefits:
Centralized location of files
When multiple developers work on a project concurrently, source control ensures that the project’s latest manifestation of its source files are kept in a central location. As a result, the project’s products can be built at any time without having to get the latest files from multiple locations.
Complete history of every file
Because all the changes made to each managed file are maintained in the repository, developers can review the evolution of each file or an entire project since its inception. This information can be valuable when investigating the causes of software bugs.
Change management infrastructure
Source control systems don’t allow developers to submit changes to the repository without describing the purpose of the change, which forces developers to document their work. This requirement saves time in the long run because it allows everybody to determine the reason for a particular change without having to consult with the person who made the change.
Snapshots provide developers with the ability to undo (and redo) change sets across several files. A snapshot is a view of the state of the files in a directory. Developers can compare snapshots to find out the differences between them, such as which files have changed and the changes made to them. Developers can also restore their working files to a snapshot, taking their project back to the state it was when the snapshot was taken. Xcode Snapshots is not a source control control system and does not interface with one. Instead, it’s a facility individual developers can use to safeguard their own work. Under standard access policies, a developer’s snapshots are not visible to other developers.
Xcode provides a common interface to various source control systems, which include the open-source Subversion and CVS (Concurrent Versions System), and Perforce. Xcode makes it easy to perform most source control tasks as you work on a project. It also tells you whether the managed files in your copy of the project differ from their representation in the repository.
Xcode users should consider using source control when several developers work on one project at the same time. Single developers may also benefit from the structure that source control adds to the development process, such as revisions and change management. As an alternative to source control, Xcode Snapshots may be more appropriate for persons who are the sole developers of a project or for developers who need to complement their repository-backed projects with a local large-scale undo mechanism.
Normally, Xcode uses the parent directory of the active project as the root for source management operations (source control and snapshots). That is, a project’s realm of source control operations is limited to the directory containing the project package. There are cases, however, in which developers are better served by telling Xcode to root source control operations at a directory higher in the file system hierarchy instead of the project package’s parent, for example, when the project the developer is working on is part of a multiproject solution. To change the root of source control operations, developers modify a project’s project root.
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)