Thursday 5 March 2009

Automatic synchronisation of OS X Addressbook without enabling Yahoo!

Update: Snow Leopard (10.6) has this built-in so there's no need for these instructions unless you're running Leopard (10.5) or lower. The following command will ensure this runs periodically:
$ /System/Library/PrivateFrameworks/GoogleContactSync.framework/Versions/A/Resources/gconsync --sync --periodic

I am using Google Sync Services exclusively to synchronise between two MacBook Pros and an iPhone.

The one caveat is that to enable Addressbook synchronisation you have to enable, say, Yahoo! synchronising before the iSync client will allow synchronisations to occur.

Oh, and it's a manual process to launch iSync client.

This is an ugly hack to an otherwise elegant solution. I don't like it.

So I went trawling the Internet to see if I could solve it.

I found an extremely informative post that outlines a lot of the work required. Then, a sprinkle of launchd to make it all work.

Here's how it's done:

  1. Add a new "google" device in your devices list:
    $ defaults write ~/Library/Preferences/ Devices -dict-add google '{ "Device Class" = iPod; "Family ID" = 10001; }'
  2. Launch Address Book and open the Preference pane. The Google contact sync option should appear.
  3. Register the sync client. Open a terminal and type the following:
    $ /System/Library/PrivateFrameworks/GoogleContactSync.framework/Versions/Current/Resources/gconsync --register 1
  4. Create the file, ~/Library/Preferences/
    {user = "";}
  5. Add a password item to your keychain with the following values:
    Keychain Item Name:GoogleContactSyncService
    Account Name:
    Password: password
  6. Create a Launch Agent. I have set the interval time to 300 seconds (5 mins). Obviously, it can be changed to something different. eg: ~/Library/LaunchAgents/com.example.gsync.plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
          <string>", Address,, Number, Address"</string>
  7. Add the agent:
    $ launchctl load ~/Library/LaunchAgents/com.example.gsync.plist
  8. Reboot. (Yes, it's required. The program, when launched from launchd, won't find the password until you've rebooted. I'm sure there's a way to do it without, but I don't know what that is.)
  9. You can kick off a sync run manually by running:
    $ launchctl start com.example.gsync
    ... or you can wait the interval period for the next run.


  1. Very nicely done. I haven't tested after a reboot but manually running:/System/Library/PrivateFrameworks/GoogleContactSync.framework/Versions/A/Resources/gconsync --sync --report 1 --entitynames ", Address,, Number, Address"worked beautifully. Thanks for figuring this out.

  2. This works beautifully!!! Great job. One caveat though. . .In step 7, you have to say . It won't work without the full path.

  3. Thanks, steadfast_i_&_i... ammended. ;)

  4. Cool (and overdue) for 10.6 to do this automatically. I note it now also syncs pictures properly too.I did an upgrade to 10.6 and notice my old launch agent is still running. It duplicates the built-in functionality, right? Should be safe to delete it and the keychain entry?

  5. Yep, you can go ahead and remove all the things in this post. ie: launch agent, keychain entry, etc.

  6. Would it be possible to adapt this to two gmail accounts?

  7. @peterI'm not sure what you mean exactly but I'll try to answer the question.Maybe.You might be able to use the service to sync to account A and use the built-in stuff for account B. This would mean that account A, account B and the stuff in your addressbook would all by synchronised to each other.I hope this answered your question and good luck!