-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Swift Cookbook
By :
It's very common starting a project without any version control, and with the passage of time, we change our idea and decide to add one.
Unfortunately, Xcode doesn't give this option to us and we have to do by hand. I hope this option will be added on Xcode soon.
To do this recipe, let's create an empty project called Chapter1 Git; however, this time before we save the project, uncheck the option Create Git CGRepository on.

Follow these steps for creating a local repository on an existing project:
cd followed by a white space. Now, without closing your terminal, open the Finder window, then go to your project folder, drag the folder from the title bar to your terminal window, and then press the Enter key.
git init git add . git commit -m "Initial commit"

AppDelegate.swift, then go to the Source Control option and select Commit AppDelegate.swift.
Unfortunately, if you forgot to add a Git repository to your project, Xcode doesn't provide any mechanism to add it to your project, so you have to add it by hand. Opening the command line allows you to use Git from the command line and Xcode detects that this feature has been added. Some versions of Xcode can only detect that the version control has been added when you open your project, so if you've done all steps and Xcode hasn't detected it, try closing and opening Xcode again.
Xcode offers you some features to work with Git and SVN, but they are very limited. If you need more commands from your VCS, you can use them from the command line, or use an external tool for it.
Even if you are not going to work as part of a team, I recommend that you use a version control system. When developing with Swift or other languages, you sometimes need to rollback or compare the current code with the previous versions of it, mainly when you have a new bug.
If you would like to know more on this topic, check out the book Git Version Control Cookbook, by Packt Publishing.
Change the font size
Change margin width
Change background colour