Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Swift 2 Blueprints

You're reading from   Swift 2 Blueprints Swift Blueprints

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781783980765
Length 276 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Cecil Costa Cecil Costa
Author Profile Icon Cecil Costa
Cecil Costa
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Exploring Xcode FREE CHAPTER 2. Creating a City Information App with Customized Table Views 3. Creating a Photo Sharing App 4. Simulating Home Automation with HomeKit 5. Health Analyzing App Using HealthKit 6. Creating a Game App Using SpriteKit 7. Creating an Apple Watch App 8. AVFoundation Index

Versioning your project

Every project should have a version control system, even if you are the only developer. Xcode works with Git as a default VCS, which has a special way of working.

Firstly, you have to know that Xcode offers you just the basic usage of Git; there are times when you might need to use the command line.

You can use Git in two ways: locally only or remote and locally. The first one is usually done by single developers and can be done very easily by checking this option when you have to select a folder for your new project. The following screenshot shows the option that needs to be checked in the file dialog:

Versioning your project

The second way of working with Git is to use it remotely and locally. What does it mean? It means that you can create versions of your code locally and when you think that it is ready to be shared with the other members of the team, you can send it to the server. To do so, you have to configure a server by yourself or you can use this service from a third-party company, such as GitHub or BitBucket.

Note

Recently, Apple announced the Xcode server, where you can configure your Git server and also a continuous integration system. Explaining how to configure this server can be very exhausting and is out of the scope of this book. However, if you would like to create your own server, you can have a look at this possibility.

As a developer what you need to work with a remote repository is its URL. You have to request it to the system administrator or you can copy it from the website where you created it. GitHub, for example, shows it on the right-hand side with a button to copy the URL on the clipboard, as you can see in the following screenshot:

Versioning your project

Once you have the URL, you can check it out by selecting the Check out an existing project option on the start up screen, as shown in the following screenshot. Or, you can click on the Source Control menu and select the Check out... option.

Versioning your project

Once you have your project checked out and have started working on it, it doesn't matter whether it was created from a server or locally only. You will notice that when a file is modified, letter M will appear next to your file name on the project navigator. Letter A will also appear when a new file is added to the project. The next screenshot shows a sample of some files that were added or modified:

Versioning your project

Note that letter M can also appear next to your project; it means that something in the project.pbxproj file, which is inside of your project package. This file contains the information of your project like the source code files with their path and the settings; hence, you have to deliver it every time you add a file or change any setting.

To commit the modified and new files, you just need to use the command + option + C key combination. A dialog asking for a description of the modifications will appear, leave a message in a way that another developer understands what was done.

Tip

Avoid committing without leaving a comment, or just leaving a nonexpressive comment like "modifications." Comments are very useful to check the project's progress and fix bugs.

These commits are done locally by default. It means that only your computer knows about your modifications. If you want to send your commits to the server, don't forget to check the option that is under the comment box, as it is demonstrated in the next screenshot:

Versioning your project

The other way around, which means receiving updates from the server, is called pull. To do a pull from the server, you just need to press the command + option + X combination key.

You have been reading a chapter from
Swift 2 Blueprints
Published in: Oct 2015
Publisher: Packt
ISBN-13: 9781783980765
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime