How I made the iPhone sync my calendar over air

Some days ago a friend of mine upgraded his iPhone to firmware 2.0, and boasted modestly on how he could sync his MS Exchange Calendar over air. Note that working calendar sync, and even by air is, of course, the holy grail of all mobile equipment, even for sales people.

Some months ago, I used the quite crude tool called ical2sqlite and some simple perl scripting, and built a proof-of-concept one-way sync from an ical source (OpenXchange) to the iPhone calendar via a Linux box. Now, recently I tested Saurik’s awsome porting work of a more or less complete Debian based GNU/Darwin userland, with dpkg, apt-get and a complete GCC based tool chain. Then the thought awoke: The hack should be doable again, and this time with nothing but the iPhone. No cross compilers. No helping computers. Just a simple over air sync.

And some hours later, it was done. The hard bits:

  • The standard C++ libraries lacked a symlink. This gave confusing linker errors.
  • GNU autotools do not support the iPhone “unix” environment yet. Thus, it was a bit difficult to get the standard configure script to understand the underlying platform, and it took a bit of guessing and trying to force through a working string.
  • Find and fix a WIN32 related bug in the ical source. (The bug is fixed in version 0.31, but I could not get that to build)

I have only tested the following on a “standard” jail-breaked iPhone, running sshd on firmware 1.1.4. You need to know the root password. Google it up and change it if you have not done so already. Note that some of the steps may take quite some time.

Also note that this is not for the faint hearted first time iPhone users. This receipe will probably brick your phone, make random calls to your friends and call them unmentionable names, spring to pieces, and hurt your uncle Bob with the shards. If something breaks, you may keep all the parts. Don’t blame me. You have been warned. On the other hand, if you know some UNIX, this is just simple downloading, patching, compiling and scriping, and no rocket science.

Remember that this is a one-way sync. All info in your iPhone calendar will be erased, and replaced with the contents of the ical source.

Start with making sure the phone does not autolock, to prevent it going into “sleep” mode, so you don’t break your network connection while it’s at its most exciting (yaaawn).

From the Apptapp installer, install Perl. Then install Cydia. This may take som time, so make yourself som coffee while you wait. Follow the on-screen instrucions.

Quit the AppTapp installer, and start Cydia. Install Tapp, wget, SQLite v3, iPhone-headers, patch, libgcc, ssh, gcc, bison, flex and make. Did I forget something? Probably. This will take a while, so drink some of the coffee while waiting.

You should now have a somewhat semi-complete GNU-like build environment on a kind-of computer that is almost, but not completely different from a GNU-based UNIX-like system.

If you haven’t done this already, change the root password. The info is all over the net.

Now log into the phone using ssh. (If you are of the kind of people that likes to hurt themselves, it might also be doable via a local console shell.)

$ ssh root@iphone

Add a missing symlink for libstdc++

# cd /usr/lib
# ln -s libstdc++.6.0.4.dylib libstdc++.dylib

Change user to mobile

# su - mobile

Now we are ready for some serious work. First, we need to get a working version of FreeAssociation, that is, libical. Note that the newer version 0.31 won’t compile because of some bison/yacc issue. If you find a solution to this, add a comment or send me a mail.

$ wget

Unpack the source

$ tar xvzf libical-0.30.tar.gz

Get a small patch that moves an error related to WIN32 away from our context

$ wget
$ patch -P0 < icaltimezone.nowin32.patch

The source needs perl to build, so add it to your path first.

$ export PATH=$PATH:/opt/iphone/bin # perl is there

Then configure and build the source.

$ cd libical-0.30
$ ./configure -build=arm-apple-darwin9.0.0d1

Have another cup while waiting. Fun, isn't it? Then Build the binaries.

$ make

Have yet another cup. Take a walk. Visit a friend you haven't seen for a while. Then return to your compilation. If you're lucky, it's finished.

Exit to root. Then install the binaries. They will go to /usr/local.

$ exit
# cd ~mobile/libical-0.30
# make install

libical is unable to use the iPhone's own timezone database, so install it's own

# cd zoneinfo
# make install

So, we have a complete libical. The next step is to get that hideous thingie called ical2sqlite. Become the mobile user again, download and unpack the source.

# su - mobile
$ export PATH=$PATH:/opt/iphone/bin
$ wget
$ tar xvzf ical2sqlite_0.1.orig.tar.gz

Now, configure and build the source. Have your coffee pot ready.

$ cd ical2sqlite
$ ./configure -build=arm-apple-darwin9.0.0d1 && make

Exit to root and install the binary

$ exit
# cd ~mobile/ical2sqlite
# make install

The binary bits are now ready. Time for some scripting action.

# su - mobile
$ wget
$ chmod +x update_calendar
$ vi update_calendar

You know how to use the vi editor, right? You should at least change username, password, timezone and zuluoffset according to your calendar settings. Correct timezone and zuluoffset=0 worked well with my settings. For more info about the script, see my previous posting.

Then, you are ready to try the magic. From Cydia, install MobileTerminal. Start the terminal. Run the script

$ ./update_calendar

You're done, and might want to check the calendar.

To access this without starting a shell, I used the tool "Tapp". Now, what I want is a tool that makes this available as a Springboard icon, but without building a complete package. I think Erica Sadun's tool "Launch" can do this, but it is not available for firmware 1.1.4.

Next stop: Make a real two-way sync? That would take som serious programming. I'm not serious.

6 Responses to “How I made the iPhone sync my calendar over air”

  1. ingvar says:

    Update: This now works with firmware 2.1. Add perl from . Install ldid and turn off code signing, as described at Configure with -build=arm-apple-darwin9.4.1 (or whatever version uname -a reports). Run ldid -S on the final binaries, including the dylibs in /usr/local/lib. Fix the scripts with correct path to perl (/usr/local/bin/perl). Ready to go.

  2. [...] somebody had got perl in a more or less usable state on the iPhone again. So I was able to make my calendar sync script work again. From the command line. Now what about wrapping shell or perl or [insert your favourite [...]

  3. jochen says:

    Very nice work!!!

    Would you consider to share the ical2sqlite and libical binaries?
    I would like to skip the whole compilation procedure.



  4. ingvar says:

    Sure. Read the README and grab the tarball from


  5. Remo says:

    Thanks very much for this work ingvar!

    Everything is working fine but the reoccuring events..
    I wrote a patch for it. You can download it at

    The perl script you wrote has also a small uncritical bug..
    The patch:


  6. ingvar says:

    Remo, nice work fixing those bugs. You may consider trying to get something through upstream. There are some guys that took Lucas’ code and postet it at . I don’t know if that project is still active. You may also try a post to Lucas. You’ll find his email adress by Google: , first hit, or you may even post a followup on his blog,


Leave a Reply