Source Control and Xcode
by Paul Hart
Up to this point I haven’t been using any source control on my iPhone project. As Sven pointed out in a comment on my last post, if I’d had source control in place, I could’ve branched my code, performed the cocos2d upgrades described previously, and merged the changes once they were successful. Instead I created an archive of the project’s state at the time.
Source control is the better solution. I’ve already had a couple of those “how do I un-break this?” moments where being able to revert changes would have been helpful. Let’s bring some control to that code.
A Plethora Of Choice
Today’s developer has many options available when considering source control solutions, rom the old-school options of RCS and CVS, through to today’s Mercurial and Git. I’ll be using Git for this project, as I already have some experience with it and I have an account at GitHub. I’ll be using GitHub to host the master repository.
Unfortunately there isn’t any integration of Git into Xcode. If you want to have that integration, then Subversion is the tool for you. Hopefully by 10.7 we’ll see more options (or a plugin system) available in Xcode. This doesn’t bother me too much, as I’m rather fond of my terminal windows (I keep Terminal in my dock).
Hub-a Hub-a
The folks at GitHub have made it extremely easy to work with Git. As I’ve already got an account there, I created a new (private, sorry folks) repository. GitHub then presents the steps required to get started with the freshly minted repository. These steps are fine for most projects as-is, but when working with Xcode there’s a bunch of stuff we don’t want to store, such as build output, and some other files need to be treated in special ways. I created a .gitignore and .gitattributes files based on the content at Shane Vitarana’s blog.
Once these additional files were in place, I initialized the repository, added everything to it, and did a first commit followed by a push to GitHub. Mission accomplished!
You don’t need to use GitHub by any means, but I like the tools and web view they offer. The important thing is having your code in a repository.