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 http://garr.dl.sourceforge.net/freeassociation/libical-0.30.tar.gz

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 http://init.linpro.no/ingvar/iphone/icaltimezone.nowin32.patch
$ 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 ftp://ftp.uninett.no/linux/ubuntu/pool/universe/i/ical2sqlite/ical2sqlite_0.1.orig.tar.gz
$ 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 http://init.linpro.no/ingvar/iphone/update_calendar
$ 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.

15 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 http://coredev.nl/ . Install ldid and turn off code signing, as described at http://www.saurik.com/id/8. 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.

    Regards

    Jochen

  4. ingvar says:

    Sure. Read the README and grab the tarball from

    http://users.linpro.no/ingvar/iphone/ical2sqlite/

    Ingvar

  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
    http://kaempfer.homelinux.org/download/configuration/iPhoneCalendar/ical2sqlite-reoccurence.patch

    The perl script you wrote has also a small uncritical bug..
    The patch: http://kaempfer.homelinux.org/download/configuration/iPhoneCalendar/update_calendar.patch

    Remo

  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 https://code.launchpad.net/ical2sqlite . 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:
    http://www.google.com/search?hl=no&q=2007+Lucas+Waye , first hit, or you may even post a followup on his blog, http://wayetender.spawnpoint.com/

    Ingvar

  7. Alma says:

    No matter what your needs browse our web site, where you may find details
    about our entire vary of autos and services, from smart to vans, fleet to
    After Sales.

  8. My brother suggested I would possibly like this website.
    He was totally right. This put up actually made my day.
    You cann’t consider simply how much time I
    had spent for this info! Thank you!

  9. Useful information. Fortunate me I discovered your
    website accidentally, and I’m surprised why this twist of
    fate didn’t happened in advance! I bookmarked it.

  10. It’s truly very complex in this full of activity
    life to listen news on TV, so I just use the web for that
    reason, and obtain the newest information.

  11. the ascent says:

    If you wish for to get a good deal from this piece of writing then you have to apply these strategies
    to your won website.

  12. Aw, this was a really nice post. Taking a few minutes and actual effort to produce a superb article… but
    what can I say… I procrastinate a whole lot and don’t seem to get nearly anything
    done.

  13. tan cang says:

    Hi to all, for the reason that I am truly eager of reading this webpage’s post to be updated daily.
    It contains nice data.

  14. I do not know whether it’s just me or if everyone else experiencing problems with your site.
    It seems like some of the text within your content are running off the
    screen. Can somebody else please provide feedback and let me know if this is happening to them as well?
    This might be a issue with my browser because I’ve had
    this happen previously. Many thanks

  15. check it out says:

    Good day very cool web site!! Guy .. Excellent .. Amazing ..
    I will bookmark your website and take the feeds also? I am satisfied
    to seek out so many helpful info here within the publish, we’d like work out more techniques
    on this regard, thanks for sharing. . . . . .

Leave a Reply