Xcode: adding source control

source control main

If you’re not yet using source control with your Xcode projects, it’s something you want to seriously consider before a project you’re working on hits serious trouble. Setting up source control is easy when you create a new project (just tick the box in the project set up window), but figuring out how to add it to projects you’ve already created is a bit more challenging. In this post we’ll look at the ‘why’ and the ‘how’ of adding source control to an existing project.

In most normal applications, ‘Command-S’, Versions, Time Machine or other back up will save your hide when you either lose a document or realise a whole bunch of recent changes are something of a disaster. Recovering or reverting a document are mechanisms Apple has put a lot of time and effort into since Lion first appeared (changes I haven’t always been a fan of…).

However, these mechanisms do not work well with Xcode due to the complex and deep links between files in an Xcode build. If you’ve ever tried to go back to an earlier version of an Xcode project or undo some change from last week, and ended up with a headache, you’ll know what I’m talking about.

That’s what snapshots are for, you say? Yes, maybe. When they work. But in my experience snapshots themselves get lost, corrupted, or simply fail to restore.

Moreover, source control has other benefits aside from recovery and reversion that neither snapshots or any other mechanism provide. It’s primary purpose is to allow you to develop parallel but different versions of your project at the same time (a process known as ‘forking’). What if you want to experiment with adding some new feature, but don’t want to risk making changes right across your code that would be needed to try it out? What if you want to create one version of your project for one set of users and another one for others, or one version for an earlier OS X iteration and another for the current release?

Let’s get down to the nitty gritty. Let’s assume you’re convinced you want to add source control to your current project. The first thing you’ll need to do is install git if you haven’t already. If you’re not sure, open Terminal and enter

git --version

If you get back a version number, continue on to the next step. If not, you’ll need to install git first. Follow the instructions for doing that here and then return to this post.

Once git is installed, here’s the steps for adding source control to your existing repository:

1. Locate the project folder
Select the project in the sidebar on the right, and click the little ‘Open in Finder’ arrow on the right.

locate parent folderl

Once you’ve got the parent folder open in ‘Finder’, quit Xcode.

2. Open Terminal and switch to the project’s parent folder
Click on the project’s parent folder icon in Finder and drag it to a Terminal.app window. Hit ‘control-A’ on your keyboard to move the cursor to the beginning of the line and type ‘cd’. Press ‘return’ to complete the command.

I always like to do a quick ‘ls’ to double check I’m in the folder I think I am, and that it contains what I think it does.

terminal 3

3. Initialize, Add, & Commit
Next, we’re going to hit a series of Terminal commands, one after the other. Press ‘return’ on your keyboard after each one:

git init
git add .
git commit -m "Initial commit"

Notice that there’s a period after a space on the end of the second command. Don’t forget to include it.

4. Confirm your local repository
Reopen Xcode, and hit the ‘Source Control’ menu. You should now see the options are active.

source control menu

Congratulations! You just added a local repository to your project. You can now go ahead and start creating branches (‘forking’) by choosing the Source Control > master > menu item.

You’ll notice that when you make changes in your Xcode project, an ‘M’ (‘modified) will appear next to the files that have been changed. When you’re happy that these are changes that you’re going to keep, use Source Control > Commit. Full documentation on how to use the various features of source control are available in Xcode’s documentation.

5. Add a remote repository
Local repositories are great, and may be enough for your needs, but for ultimate protection (such as against disk loss or failure), you might want to add remote back up. To do that, you’ll need an account with a service like GitHub or Bitbucket. My own personal preference is Bitbucket, largely because they allow you to have private repositories on a free account. Steps for adding your existing project to a remote repository can be found on your chosen service’s website.

how to remove Google’s secret update software from your mac


If you’ve ever downloaded Chrome, even for just a trial (guilty!), you might not be aware that Google have slipped a little bit of hidden software into your Library.

This software is called Google Updater, and it secretly “calls home” on a regular basis and downloads updates to your Google software without either asking before, or notifying you after, doing so. In Developer circles, this is considered very shady practice. Users should be asked for consent and informed when software makes changes to either itself or the user’s computer, and ideally those notifications should tell the user what has been changed and how the changes could impact them.

Before I beat this drum any harder, however, I owe you at least the other side of the story. If I worked for Google, I’d probably come up with this response: “Hey look, a major source of computer virus and malware infections is that users are often using out-of-date software that hasn’t been patched to combat newly-discovered exploits. No matter how much we tell users to keep ther software up-to-date, the truth is the majority don’t. We provide an automatic updater so that users don’t have to worry about it, and can be assured they’re always using the latest and safest version of our software”.

I’ve heard this argument so many times, I don’t doubt it’s something close to what Google would actually argue. My problem with this is that while automatic updates can be a good thing if they’re security related, it’s not at all clear why an app should be updating itself automatically for any other reason, or why it’s updating itself without providing notifications about when and what updates were made.

If an independent developer did that, they’d almost certainly find their software labelled as “suspicious” at best, and “dangerous” at worst. The fact that Google is a multinational, global enterprise with a stranglehold on the internet, and which is often tangling with the law in countries throughout the world, may make you feel more or less confident that they can be trusted more than independent developers, whose income depends very much on their reputation. I’ll leave that one for the reader to decide. ;)

Do I have Google Updater?
To see if you’ve got Google Updater hiding on your system, try this quick test in Terminal. Triple click the line of code below to highlight it.

defaults read com.google.Keystone.Agent

If you’ve previously installed my Terminal workflow, just hit control-opt-cmd-T or right/control click and choose “Services > Run in Terminal” from the contextual menu. Elsewise, manually copy and paste it into a Terminal window.

If the result comes back as

Domain com.google.Keystone.Agent does not exist

you’re fine. Google Updater has not found its way into your system. Anything else and you’re going to need to decide whether you want to remove it or not. If you’re a regular Chrome user, keeping Updater might prove convenient, though you’ll have to live with the idea that the app is updating itself in ways over which you have no control. If you rarely or never use Chrome, there’s no reason to have this hidden process regularly calling home to Google every time you’re connected to the net.

How do I remove it?
You have two options. You can either disarm it or you can nuke it. Disarming it is simplest, it’s a one-line Terminal command:

defaults write com.google.Keystone.Agent checkInterval 0

This command tells the Updater how often to “call home”. A value of 0 basically means ‘never’. Disarming it is probably better than nuking it if you still keep Chrome on your system and use it occasionally. You can temporarily set it back to something like ‘once a week’ from time to time to check for security updates with

defaults write com.google.Keystone.Agent checkInterval 604800

Nuking the Google Updater is a bit more complex. You’ll want to run some uninstaller commands, and then you’ll want to go and clear up the crud that is still left behind. And before you can do either of those, you need to find out where it’s hiding. So, we have a three-step process.

1. Locate Google Updater
Triple click the first of these two lines, and choose ‘Services > Reveal in Finder’ from the contextual menu (that’s another right-click or control-click on the selected line), and then repeat for the second line:


You will likely get the error message “The operation can’t be completed because the item can’t be found” from one of these lines, but not the other. Note that the difference is all in the presence or absence of the tilde ~. Make a note of which one worked, and run the appropriate commands in step 2.

2. Run the uninstaller commands
Run these in Terminal (again, triple clicking to highlight and doing the usual trick afterwards with shortcut key or Services menu if you have my workflow installed), one at a time:

If the Updater was in your user library (with the tilde ~), then first do this (it’s all one line):

python ~/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/\
install.py --uninstall

then this:

touch ~/Library/Google/GoogleSoftwareUpdate

If the Updater was in your domain library (no tilde ~), then first do this (it’s all one line):

sudo python /Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/\
install.py --uninstall

and enter your Admin password (note that you won’t see any indication of your password being typed in the Terminal window). Then do this:

sudo touch /Library/Google/GoogleSoftwareUpdate

3. Clear up the crud
If the updater was in your user library, open that now and go to


and delete the folder called ‘GoogleSoftwareUpdate’. If you don’t use any other Google software (I don’t), you can just delete the entire ‘Google’ parent folder.

If the updater was in your domain library, search for the same folder and send it to the trash. You will need to give Finder your admin password to authorise the move.

Next, let’s just check the uninstaller was successful. Look for the following. If you don’t find them, good (the installer did its job). If you do, help them on their way to oblivion by sending them to the trash:


If you’ve deleted Chrome from your Applications folder too, then you might as well hunt down and exterminate its prefs list while you’re at it:


The following sources were used in researching this post:




‘Don’t be evil’ picture was remediated from here.

FastTasks 2 – take the toil out of Terminal 💥

FastTasks 2.0 I’ve just released the first build of FastTasks 2 over on my software website Sqwarq.com.

FastTasks 2 is a menu-bar app that takes the toil out of Terminal and offers at-a-glance display of key system info, the ability to quickly toggle hidden files, free memory, remove login items and create a super-fast RAM disk.

All told, FastTasks 2 offers more than a dozen tasks that you can accomplish with little more than a click. Check out the screenshots below to get an overview of the main features.

When you’re ready, head on over to the FastTasks home page to download your free copy, and forget looking up tiresome Terminal commands – just click and the task is done! FastTasks 2 contains no adds, nags or in-app purchases and is currently on offer for free, so go get one now!

FastTasks 2 requires OS X 10.9 or higher.

Toggle system settings



how to save and print email attachments

I was recently asked for a script that would automatically save and print all the pdfs from one particular client’s emails. Since this is quite a common use case (think invoices from a particular supplier, for example) and involves a fair bit of complexity, I thought I’d share the answer for any others out there that have the same need.

We’re going to need to do three things; install a script, set up a mail rule, and set up folder actions. Here we go!

Part 1: Install Script

Copy and paste the script you see below from here:

save mail attachmentsSave this script with a name like ‘CopyAttachments’ in

~/Library/Application Scripts/com.apple.mail

(note: ~/Library means your user library. You can find it by triple-clicking the path above, then control-click on the highlighted text and choose Services > Reveal in Finder)

Part 2: Set up Mail Rule

Open Mail.app. Click on your Inbox in the sidebar. Click ‘Mail > Preferences… > Rules > Add Rule’

Under ‘Description’ give the rule a name (e.g., ‘Copy attachments’)

Set ‘If ANY of the following conditions are met’:


‘From contains’

and the email address of the person whose attachments you want to target.

(note: You can add more than one person’s email if you wish, but you do so by hitting the ‘+’ key and adding a new condition, not by adding more than one address in the text field. Each text field must contain only one condition, i.e., email address or keyword).

Next, set ‘Perform the following actions:’


‘Run AppleScript’

Click the ‘No Script Selected’ button and choose ‘CopyAttachments’

Click ‘OK” and in the following dialog click ‘Apply’.

3. Create & Set up a Folder Action

Open Automator.app. From the open panel choose ‘Folder Action’.

In the large, empty panel at the top you’ll see

‘Folder Action receives files and folders added to’ Choose folder

Click the Choose folder menu, choose Other. Select the folder you want the attachments to be saved in.

In the filter/search bar on the left of the Automator window, type ‘print images’. Drag the ‘Print Images’ selection from the results list into the middle of the empty workflow and release.

You can set some options here if you like (‘scale to fit’ might be useful).
You can choose either ‘Default Printer’ or click to select your actual printer. If your actual printer is the default, it won’t make any difference.

Press ‘command-S’ on your keyboard to save. Supply a name (e.g. Print PDFs) and hit ‘OK’. You do not choose a save location.

Quit Automator.

Open a Finder window and navigate to the folder where the attachments are going to be saved.

Hold down the ‘control’ key on your keyboard and click the attachments folder. From the contextual menu, go to Services > Folder Actions Setup… and click to open the dialog box.

Navigate down the list of scripts till you see the name of the Automator action you saved above and select it. Click ‘Attach’.

In the parent dialog box, check the box at the top that says ‘Enable Folder Actions’ and ensure that in the list on the left the attachments folder is listed and checked. Check that on the right, the ‘Print PDFs.workflow’ is checked.

If all is in order, close the dialog box. The procedure is complete and the workflow is installed.


It’d be wise to test the script as soon as possible. If it fails to work, double check that you’ve entered the correct path in the AppleScript as that’s the most likely point of failure. Let’s suppose your hard disk is called ‘Macintosh HD’, your user name is “Mack” and the folder you want to save the attachments in is “Invoices From Acme”, then the set attachmentsFolder line should look like this:

set attachmentsFolder to "Volumes:Macintosh HD:Users:Mack:Invoices From Acme:" as rich text

You must ensure you’ve already created the folder ‘Invoices From Acme’ before running the script. Also, be sure you don’t forget the trailing colon at the end of the path and that you have a matching pair of opening and closing quotes around the path name.

Any problems, drop me a comment below and I’ll try to help you out. Good luck and enjoy! :)

FastTasks version 1.18 released! 💥

FastTasks v.118

I’ve just posted an incremental update to my free system utility, FastTasks. The update fixes a bottleneck in the launch code that caused FastTasks to take excessively long to load. I’ve also added the System Uptime, which you can also refresh with the new keyboard shortcut, ‘command-U’.

FastTasks saves you having to role up your sleeves and get mired in the exotic world of Terminal’s command line for a number of common tasks. FastTasks v1.18 offers you system info down the left side of the panel, all of which can be updated by the shortcuts displayed on the panel, and access to some common Terminal commands on the right.

If you haven’t tried FastTasks yet (or got tired of the slow launch times with the old version), this is a great time to grab a free copy of v1.18 as I’ll soon be replacing the app by FastTasks 2.0, a paid-for app with a whole new interface and extra functions. Nevertheless, support for FastTasks 1 will continue and bug fixes will still be forthcoming as necessary. Grab it while you can, folks! :)

Download FastTasks v1.18 from here…

Note: FastTasks requires OS X 10.6.8 or higher

run Terminal commands from any app

In this post I’m going to show you how you can select a piece of text in any app and have it run in Terminal simply by hitting a hotkey. The trick is especially useful for running commands you find on websites (like this one!) in a browser like Safari or Firefox.

This 20-second clip demonstrates running a command from a Firefox browser and another one from TextEdit, but you can also do it from an AppleScript editor window (and indeed any app that has selectable text), which can be useful for testing the formatting of your ‘do shell script’ commands and the like:

The first thing you’re going to need is to create an Automator workflow, add an AppleScript action and insert some code. Really? Nah, just kidding. I did it for you. :) Just download, unzip and double-click the .workflow file to install the completed Service:

Download Run in Terminal.workflow.zip

Click through the various dialog boxes and choose ‘Install’ on the last one* (note for Snow Leopard users: the service will open directly in Automator; just do ‘command-shift-S’ to name it and save it).

Screen Shot 2014-05-09 at 12.10.58

All you need to do now is set the hotkey. Open  > System Preferences.. > Keyboard | Shortcuts and click ‘Services’ in the sidebar. Scroll down the window till you see the ‘Run in Terminal’ command. Click on the far right to add a shortcut of your choice. The one I used in the video is ‘command-option-control-T’ (‘T’ for ‘Terminal’ helps me remember the shortcut).

To use the Service, just highlight any Terminal command by triple clicking it and pressing your hotkey. Try this one,

cd ~/Desktop; ls -alF

which lists all the visible and invisible files on your Desktop, as a test.

You can also get to the Service from both the contextual menu (right-click > Services) and the application menu bar at the top (e.g., Safari > Services).

As a bonus, try out your new Service on the Terminal command in this post, and now you’ll be able to run Terminal commands even from Quick Look previews in Finder!

Enjoy! :)

enable trackpad zoom in Firefox

With Firefox 29 just out, I’ve been testing it out as an alternative to Safari. However, if you’re new to Firefox you’ll probably find that the trackpad pinch and zoom gestures are not set by default. To turn them on, you’re going to need to do a bit of tinkering.

Open Firefox and type


in the address bar. Then type ‘browser.gesture’ in the search field and make the following changes to the ‘Value’ field for each of these preferences:

browser.gesture.pinch.in -> cmd_fullZoomReduce
browser.gesture.pinch.in.shift -> cmd_fullZoomReset
browser.gesture.pinch.out -> cmd_fullZoomEnlarge
browser.gesture.pinch.out.shift -> cmd_fullZoomReset
browser.gesture.pinch.latched -> false

Optionally you might want to also reduce the browser.gesture.pinch.threshold (I’ve got mine on 60).

Carbon Copy Cloner: see last back up date

CCC Last Backup Service

If you’re a user of Bombich Software’s excellent Carbon Copy Cloner but you’re not doing backups as scheduled tasks, you may wish there was a way to find out the last time you successfully completed a backup task.

Unfortunately, CCC doesn’t provide an easy way for users to see this information natively, but in this post we’re going to add it through a bit of AppleScript and Automator magic.

As it turns out, CCC does keep a log of all your past backup details stashed away in a CCC.log file buried in your local domain’s Library folder. You can view this file in Console, but it’s a bit of a pain. Wouldn’t it be nicer if you could just hit a hotkey like ‘Command-Control-C’, say (you know, for ‘CCC’ :) ), and get a dialog box like this:

CCC Last Backup date
If you think so too, then download my Automator workflow:

For Lion, Mountain Lion and Mavericks:
Download for 10.7.5 thru 10.9.2 📀

For Snow Leopard:
Download for 10.6.8 💿

Double-click on the .zip file and double click again on the unzipped workflow file. You’ll get a warning message saying that you’ve downloaded the file from the internet (from me, actually!). After clicking ‘Open’ to dismiss the warning, for all users except 10.6, click ‘Install’ on the the following dialog box:

Install workflow

After clicking ‘Install’, click ‘Done’ to dismiss the confirmation dialog box that pops up.

For those of you running Snow Leopard (10.6.8), after clicking ‘Open’ the workflow should open in Automator. Hit ‘command-S’ to save it as a Service.

For all users, if you now click up to any application name next to the  Apple near the top left of your screen (see the screenshot at the top of this post) and scroll down to ‘Services’ you should see the new Service already there. If you don’t, try logging out and logging back in to your user account.

Once you can see the workflow in the Services menu, go ahead and give it a click to test it out. :)

A couple of notes on usage:

Carbon Copy Cloner does not have to be open for the Service to work.

The date format display is YYYY-MM-DD.

If you want to add a shortcut key as suggested earlier, open up System Preferences > Keyboard and click the ‘Shortcuts’ tab. Down the sidebar you should see ‘Services’. Click on that and scroll way down to the bottom till you see the name of the Service. Click ‘Add Shortcut’ and hit the keys you want to use. I like ‘command-control-C’ as it’s an easy mnemonic for ‘Carbon-Copy-Cloner’.

how to clear Safari’s cookies on quit

If ever there was a free app that deserved more recognition, it’s Safari Cleaner. Developed out of a simple applescript, this app does what many people would expect Safari to have an option to do in the Preferences panels: automatically clear stored information when Safari quits.

Personally, I’ve found this particularly needsome since signing into any Google service seems to be particularly irritating. Gmail, for example, needs several clicks just to be told that you don’t want to be remembered. Safari Cleaner takes care of automatically ‘forgetting’ as much or as little info as you want without you having to remember to clear cookies or caches. It’ll also, thankfully, forget Top Sites. :)

Safari Cleaner

Personally, I leave my history as that’s something I regularly need across sessions, but the rest, I’m happy to be forgotten. If you’re wondering why anyone might care, well, there’s a whole bunch of reasons including protecting you from malware and malicious websites, but at least one other is nicely detailed in this Ars Technica article, which explains how cookies can be used to track your physical whereabouts.

One caveat to note with Safari Cleaner: in my tests, I’ve noticed that if you click and restart Safari in rapid succession (within about 5 seconds or less), the script hasn’t had time to complete running and caches and cookies aren’t cleared. To be safe, you probably want a nice 10 secs or so between quitting and relaunching Safari if you absolutely must be sure the previous session was wiped out.

Once you’ve run and set up Safari Cleaner’s options, you can quit the app and it’ll just carry on working in the background. Launch the app only if you want to change your options. If you want to uninstall it, note that there’s an uninstaller in the DMG, so don’t throw that away.

Get Safari Cleaner…

advanced search in Preview


Unlike Adobe Acrobat, you won’t find any complicated advanced search boxes in Preview, but that doesn’t mean you have any less power to find exactly what you want. Feel free to open up a pdf that you can play around with as we go along.

Finding stuff
Preview does all its searching in the spotlight-like filter field in the top right, and you access it either by clicking in it or hitting ‘command-F’.

Simply typing in a few letters will return every page that contains that string, either as a word or a partial word. If you want to restrict the results to complete words – say you type in ’cause’ but you don’t want it to return ‘because’, then add double quote marks around what you type.


If you add another word (or words), also in double quotes, this is effectively telling Preview to return only those pages that contain all those complete words on the same page. Thus

"cause" "pattern" "function"

will only return pages in your pdf document that contain all three of those terms. This is the same effect you get when you put the ampersand ‘&’ between words (the logical AND), but the & is automatically implied by default, so there’s no need to actually type it.

What if you want to return all pages that have either “cause” or “function” in them? In this case, you use the ‘|’ sheffer stroke (hold down shift and hit the backward slash key, up their above the return key!).

Note for the techies: Preview doesn’t distinguish between NOR and NAND. Though both are valid input, one sheffer stroke will return the same as two.

As with the logical ‘AND’ function, you can have as many terms as you want. For example, if you wanted to return every page that had a numeral in it, you could use

"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0"

That would return every instance of any one of those digits on their own, but it wouldn’t return a page that had, say, ’2014′ in it. Remember that the quote marks indicate whole expressions, not parts. To get any number, do the same without the quotes:

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0

You could even combine this with word searches:

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | one | two | three | four | five | six | seven | eight | nine | "ten" | eleven | twelve | thirteen | fourteen | fifteen | sixteen | seventeen | eighteen | nineteen | twenty | thirty | forty | fifty | sixty | seventy | eighty | ninety | hundred | thousand | million | billion | trillion | zero | nought | nil

That would return every mention of any number in numerals or words. Note that “ten” is delimited as a complete word due to the number of false positives that would arise from words with those three letters (heighten, often, tendency, etc). Also notice the various synonyms for ‘zero’ at the end of the search term. Even so, it isn’t quite complete – the assiduous search-hound would probably want to add ordinals, ’1st’, ‘first’, ’2nd’, ‘second’ and so on, but I’ll leave that as an exercise for the reader.

Organising results
OK, so you’ve got your results, what can you do with them? First of all, note that you’ve got some options above the search sidebar. You can list by page order from beginning to end of the document, or by number of hits per page with ‘Search Rank’. Highest number of matches on a page appears at the top of the results and the rest follow in descending order.

Screen Shot 2014-03-22 at 00.10.14

Secondly, you can cycle backwards and forward through the hits on each page by using ‘command-G’ and ‘command-shift-G’, respectively. That’s a whole lot less laborious than clicking the tiny forward and backward arrows under the filter field, but that way is available too.

filter bar

The filter field
Finally, don’t forget that you can move the cursor around in the filter field with a few shortcuts: both ‘control-E’ and command-right arrow will put the cursor to end of the search term, while ‘control-A’ and command-left arrow will put it at the beginning. You can also use ‘control-K’ to delete everything from the cursor to the end of the search term, which can be handy if you have a lengthy search term that you want to cut in half. Move the cursor to where you want the search term to end, and hit ‘control-K’ to delete all subsequent characters.

Hopefully, that should give you some pretty good ideas on how to power search in Preview. Who needs ‘advanced search’ dialog boxes? Not us! :)

featured picture: searching for light by HealingRock

%d bloggers like this: