Jun 16

In my day job there is a heavy emphasis on building and testing software using Continuous Integration.  To quote from Martin Fowler’s site:

Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily – leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible.

To manage the automated builds, including (smoke) testing, we use a free open source tool called Hudson.   It’s written in Java, so you can run it on your Mac, Linux, Windows, etc.  You can run it as part of a server, or stand-alone.

I decided to look around and see if anyone was using Hudson to build iPhone and Android apps.  I found a great article that covers the process:

How to automate your iPhone app builds with Hudson by Michael Nachbaur.

If you’re an indie developer, you may be thinking that this doesn’t apply to you.  But think of the advantages:

  • Tests are automatically run to see if you broke something
  • Test apps can be automatically distributed to your Web site for Beta testing
  • Wrestling with certificates, etc, can all be automated
  • Build numbers can automatically be integrated
  • Multiple build configurations can be automated
  • It forces you to think about managing your code through source control. :)

Even though I use Hudson at work and have installed a stand-alone copy on my Mac at home, I haven’t tried this yet.  But I’m thinking of buying on of those new (er, admittedly over-priced …) Mac-Mini’s in the next month or two and setting something up.

Tags:

Sep 04

Over the years I’ve worked with many source control management systems (CVS, SVN, SourceSafe, PerForce).   The problem is that they are oriented towards a central server.  Git on the other hand is a new and improved type of source control.  It can work with a server - in fact, it can work with many servers.  But it can also work with just your collaborators workstation across the hall – bypassing the need for a server completely.

If you are just working by yourself (as many iPhone developers are) you can run it on your local workstation – even without a network connection.  If later you want to make your repository available to others — or just create an offsite backup — you can either open up a share on your workstation or clone a repository to a server.

Instead of going into too much detail, I’m just going to provide links to resources for you to look at.  You can decide for yourself if it is right for you:

  • Git Home Page
  • http://progit.org/book/ - A free Web-based version of the book Pro Git.
  • Pro Git on Apress – You can help the author of Pro Git out by buying a PDF or hard-copy.
  • Git for OS X – This is what you’ll need to install it on your Mac.  In my case I had to make sure that I got the latest Intel / Leopard DMG file.
  • Installing Git on Leopard – For the most part you will just want the Git for OS X installer – but see the notes on setting up your config.
  • Gitx – GitX is a git GUI made for Mac OS X
  • Heroku tips on Git – Heroku is a cloud-based host for Rails apps – but you may find some of the generic tips and links useful.
  • Windows Installer – Why would an iPhone developer need a Windows installer?  It could make it easy to trade *.cpp files with your PC.  Plus you can use it for your other projects.  Git is platform independent.
  • GitHub.com – Free hosting for your open source projects.  Paid options also available.
  • Unfuddle - Also offers free hosting.  Unlike GitHub, the free plan can be private.

Installing on the Mac

When you download Git for OS X the DMG file should open up.  Launch the installer.

After installation completes, open up a terminal window and configure it via the command line (substitute your name and e-mail address):

git config --global user.name "John Doe"
git config --global user.email "john.doe@gmail.com"

When that is done type the following:

git config --list

Ignoring Files

On a PC, you would see several items listed.  On the Mac, apparently you have to set those yourself.  See the link Installing Git on Leopard for what other globals you have to set.  Be sure to configure the ability to use a .gitignore file for filtering what goes into the repository.

The link suggests that you put your .gitignore file in your user directory.  I prefer to put the file in the root of the project.  Yes, it is a hassle to always copy the file from project to project.  But it helps you make sure that whomever else downloads your repository has the right filter too.

So I would configure my globals like this:

git config --global core.excludesfile .gitignore

For iPhone SDK projects, here is what I have for a .gitignore file:

# xcode noise
build/*
*.xcclassmodel/*
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
 
# old skool
.svn
 
# osx noise
.DS_Store
profile

Here is what I have for .gitattributes – which also sits in the root directory of the project:

.pbxproj -crlf -diff -merg

For more info, see these links:

http://shanesbrain.net/2008/7/9/using-xcode-with-git

http://rudifa.wordpress.com/2009/05/19/git-xcode-and-projectlocker/

Hidden Files

One thing to note is that when you create a local repository it goes into a subfolder called “.git” under your projects directory.  On Windows you can see this folder.  It’s hidden by default on the Mac.  The same is true for .gitignore and .gitattributes.  If you are in a Terminal window, you can view hidden files using the -A flag for ls.  Example:

apple$ ls -l -A

If you would like to be able to view hidden files and folders in Finder enter this line from a Terminal window:

defaults write com.apple.Finder AppleShowAllFiles YES

The hidden files won’t appear until you restart Finder.  For more info, see this link. (Note: their steps for restarting Finder didn’t work for me – I just rebooted).

Git Hosting

If you do decide to setup a Git server, it can be a bit of work.  To get around that problem at work I just use file shares.  The good thing about Git is that it can refer to a server based reposiory either via http:// or file:/// (example:  file:///\\mywinsever\git\myproject.git – note that there are three slashes after “file:” ).  If that makes no sense to you now, don’t worry.  It will once you come up to speed.

If you want to share your project with the world, hosts like GitHub.com and Unfuddle can also save you a lot of work.   These sites are new and suffer from a lack of documentation.  But if you don’t mind being on the bleeding edge you may find them useful.

Tags: