Calabash for testing iOS apps Part 1

Installing calabash on a vanilla mac is not a 2 minutes process. There are number of packages that you will need on your machine in order to make the set up and use of calaba.sh possible.

Those items are:

  • Xcode
  • Xcode command line tools
  • Ruby min version 1.8.7
  • Homebrew
  • Github
  • RVM (if you don’t want to mess around with your main Ruby install – this is not a MUST but I highly advice you to install it)
  • Calaba.sh

This guide will take you through that process.

Xcode

  1. Get Xcode (if you haven’t got it – get it at the App Store)

Command Line Tools

Note – you may need an Apple developer log-in to get the command line tools

  1. Get the Command Line Tools for Xcode – the easy way to get these is to open Xcode > Got to Xcode on the menu bar, then click Open Developer Tools, then click More Developer Tools… – this will take you to a page will have the latest version of Command Line tools at the top – just download the dog and install.

Check that the command line tools have installed properly by running:

$ gcc —version

You should get a response similar to this:

Configured with: —prefix=/Applications/Xcode.app/Contents/Developer/usr —with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

If you get:

clang: error: no input file , don’t panic, you’ve probably typed gcc -version (1 hyphen) instead of gcc —version (2 hyphens)

Homebrew

  1. Now this is an optional step, but if you don’t have home-brew installed on your mac then I suggest that you do. It is a package manager which makes installing a whole host of tools as easy as stating typing ‘brew’ at the command line.
  2. As a pre-requisite to doing this, just double check that you have ruby installed and check that the version is at least 1.8.7. To do this enter:
ruby -v

You should see a response saying something like:

ruby 1.8.7 [patch info] [other info].

OK – now to install home-brew – enter at the command line. Please note – you may have to prefix this with sudo or run as admin/root.:

ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”

When the installation has complete, execute the command brew doctor at the cmd line to check that the install is ok. If there are any problems, go through and fix them one by one…running brew doctor until there are no more issues. – Issues that I encountered were numerous to be honest – such wrong version of Xcode; macports being installed and various other things.

Git

  1. So we have brew installed – time to install Git. Git is a version control system. The calabash code is held in github.

First thing we do is run at the command line:

brew update

It is good idea to get into the habit of running brew update before installing anything – it makes sure we always have the most recent copy.

So to install git – we can use the magic of home-brew by entering the following at the command line:

brew install git

When it’s finished we get something like this before our prompt:

🍺 /usr/local/Cellar/git/1.8.4: 1339 files, 30M

Next thing we do is run ‘brew doctor’ to make sure everything is still ok.

In my case I already had an install of git and had to overwrite it.

Now very your installation of git by entering

$ which git

you should get

$ /usr/local/bin/git

Let’s now configure git with you name and email address. so on the command line enter

$ git config —global user.name “Gin AN Tonic”

$ git config —global user.email “gin@drinkitup.co.uk”

Install RVM (with the latest Ruby on Rails)

  1. Now this is the last part before calabash itself. We are going to install RVM and while we are at it Ruby on Rails. Go to the command line and enter:
$ \curl -L https://get.rvm.io | bash -s stable —rails —autolibs=enable

When it has finished installing, check it with the following command:

$ type rvm | head -1

response should be

rvm is a function

Now check the versions of both rvm, ruby & rails…enter

$ rvm -v

response should be dvm 1.19.1 or higher

$ruby -v

response should be ruby 2.0.0p0 or higher.

$ rails -v

response should be Rails 3.2.13 or higher

Lastly check that everything is ok with homebrew by running brew doctor again. You might seem some messages saying that the kegs in the cellar are unlinked. Brew gives very explicit instructions – follow them and you will easily be able to link, relink or overwrite any kegs which are causing problems in your cellar.

That’s it for the moment.

In PART 2 – using RVM to manage your versions of Ruby, installing calabash and running our first test.

Advertisements

How to stay focused – Time Management for the home worker

Working alone and from home, I have really struggled with staying focused on client work. I love to read and learn new things, so I find myself continually looking at twitter and web development websites throughout the day. I was on occasion finding that I of the 8 hours that I had been at my desk, I had spent only 2 hours working on billable projects. This is clearly a model that will not sustain my lifestyle, so something had to change. This post will therefore show how I have adopted some time management systems and tools in an attempt to stay focused, increase my concentration and ultimately boost my productivity.

Time Sink

First I tried the app Time Sink (http://manytricks.com/timesink/) by Many Tricks. It certainly told me where my time was going, but stop me from going there! I needed something to physically limit my digital wandering…so I installed…

Self Control

Self Control is a free app available for the MAC from http://selfcontrolapp.com. This seemed to be just the thing I needed, it allows you to block every site on the internet (except for those on your whitelist) thus allowing you to get to http://www.stackoverflow.com for those important development answers, but not get to http://www.buzzfeed.com. To be honest, Self Control was not the first app of this kind I had tried but it was the only one which didn’t reset after a reboot. …terrible I know, it’s like I should be in rehab – I mean rebooting my machine just to get to http://www.bbe.co.uk/news because I hadn’t looked at it for 10 minutes. ..I think it’s called information addiction – or if it’s not it should be.

So anyway, this little app allows you to set a timer for a time period of your choosing and on pressing Start, it blocks all those internet sites and twitter & facebook apps that eat up your time…and best of all, no amount of rebooting unblocks them. Of course if we really wanted to reset it, there a number of things we could do – but are we really that desperate? As it turns out, we probably are – my kindle fire seemed to be making frequent trips to my desk. That aside – it is a great app. I found setting the timer for smalls chunks like 15 or 30 minutes to be most effective. I generally just kept on working right on past the timer end for another 15 or 30 minutes.