I recently had a problem with iCal syncing to my iPhone: Calendars would sync fine from the Mac to the iPhone, but any event entered on the phone would not sync to the Mac. Moreover, calendars deleted from iCal on the Mac — calendars that no longer existed — would still be available for syncing in iTunes. Clearly there was a problem with cached data of some sort, somewhere. But where?
After a lot of trial and error, and hunting around — I tried resetting iTunes preferences, iCal preferences, and anything else that might present an easy fix — I finally figured out where all this data gets mashed up. There are two folders in your home account that are responsible for syncing the databases between your iPhone and your Mac. The first one, as far as I can tell, just contains a backup of your iPhone data. It is:
The second is where all the syncing action happens:
To fix my problem, I renamed these two folders. They'll get recreated the next time you sync your iPhone and you can keep these in case anything goes wrong. Then start up iTunes and reset all the items under the Info tab for your iPhone. (Fortunately, items under the other tabs seem to have been left alone, at least in my case. YMMV.) I still couldn't see my calendars in iTunes at this point, but I went ahead and just hit the Sync button. And it worked.
Everything now appears properly in iTunes. New calendars show up; deleted ones disappear. And syncing calendars between my iPhone and my Mac works perfectly now.
Reader Ferdinand points out that Apple strongly discourages the removal of the SyncServices folder. Instead they recommend resetting your SyncServices with the instructions in this article for Mac OS X 10.5 or this one for 10.4. I'm quite happy I didn't have any problems, but if you need to mess with your sync services, I strongly recommend following Apple's advice over my own.