Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,020
164
Norway
I'm having a problem with the Calendar app where old calendars that I've previously deleted reappear whenever I sync (via a USB connection and iTunes) my iPad or iPhone with my Mac.
(I've previously adressed this problem earlier, but it turns out the sync issue is twofold, but I've luckily found a solution to why I couldn't sync Contacts with the iOS devices. I'm still struggling with syncing of the calendars though.....).

What happens is that whenever I start up the Mac iTunes app, attach my iPad (iPhone) with a USB cable, then go to the "Info" section (where you can enable/disable Calendar and Contacts sync), I actually see more calendars there than are actually available in the Mac Calendars app. It shows calendars that have previously been deleted.

screen-shot-2022-05-18-at-09-32-09-png.2006366


What happens when I perform a sync (at least when I've chosen to sync all calendars, which I usually do in order to keep things simple) ALL those calendars pop up on my iPad/iPhone.
So I figure that I need to delete something in order to make those old calendars go away. The problem is figuring out where the calendar files are located and how to delete them. This is what I've tried so far (without any success):

Old calendars on the iOS device?
Assuming the offending calendars are located in the iOS device (iPhone or iPad) -because they show up in Mac iTunes when the iOS device is attached; I do the following when the iPad or iPhone is attached (USB cable) to the Mac with iTunes running:
a) in iTunes: turn OFF sync of calendars
b) when asked if I should keep or delete the calendars already in the iOS device, I choose to delete them.
c) then I press the "Apply" button to perform the sync and changes
d) just to be on the safe side, I eject the iOS device, disconnect the USB cable, then power it down (the iOS device). 30 seconds later or so I power the iOS device up again. This to ensure its caches are flushed and all changes have been set correctly

But no.....
When I power up the iPhone, attach it to the Mac and start iTunes again I still see the old calendars there, so.... it's obviously not the iPhone that keeps those files (or they're well hidden in some secret compartment or something).

Old calendars in the Mac Calendar app?
It's now fair to assume the previously deleted calendars are somehow in the Mac Calendar app, even though they're now shown there, so having made a backup of my calendars (using its "File"-"Export" menu option for exporting the entire setup or each calendar individually) I want to reset everything to empty (i.e. factory defaults), then, when confirming those old calendars are gone for good I'll be re-importing my valid ones.... so this is what I've done:

- delete the Calendar cache
a) eject (from iTunes) and USB-disconnect the iOS device from the Mac and quit the iTunes app
b) quit the Mac Calendar app
c) delete the Calendar caches by first opening the following folder: ~/Library/Calendars/
then delete the following three cache files:
Calendar Cache
Calendar Cache-shm
Calendar Cache-wal


d) now start the Mac Calendar app again and you'll only see a couple of calendars there ("Home" and "Work" I think), but after a few seconds all the calendars reappear, including the ones I had deleted, so this doesn't work either. Let's try something else.

- delete all the Calendar files
So now let's try to completely delete all the calendar data so that it's reset back to the factory settings (i.e. empty):

a) if applicable; eject (from iTunes) and USB-disconnect the iOS device from the Mac and quit the iTunes app
b) quit the Mac Calendar app
c) delete the entire Calendar folder: ~/Library/Calendars/
d) start the Mac Calendar app. You'd expect it to show up with just the default (factory preset) calendars, but no! -once again ALL the calendars show up there (including the old ones you deleted in the past) and the ~/Library/Calendars/ is repopulated with all the calendar data and cache files.

So I conclude with this that the actul calendar data isn't contained within ~/Library/Calendars/ but fetched from somewhere else, but where? I obviously need to reset/flush something else so that the Calendar app will stop fetching old junk.
Does anyone have any ideas where and what to do?
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,837
8,605
A sea of green
I suggest deleting the Calendars by logging into your iCloud account using a web browser, then inspecting (and possibly deleting) them there.

All the scenarios under Old calendars in the Mac Calendar App seem like the same basic premise to me.

Imagine the following: you buy a new Mac, and tell it your AppleID. Presumably, there are no Calendars on the new Mac, so the proper thing that should happen is for it to download them from the master source. That master source seems to me like it would be the iCloud account for the AppleID, what you call "somewhere else" in your last paragraph. It seems completely illogical to me for iCloud sync to treat the Mac as the master version, since you'd never be able to setup a new Mac and have it download stuff from iCloud (i.e. sync).

As a test, I'd probably make a new disposable Mac user account, log into it, give it your AppleID, and see what Calendars show up. This might take a while, depending on how much overall data has to sync from iCloud.

As a further test, I'd log into iCloud using a browser, create a Calendar there, and see if it eventually shows up on the Mac and/or iOS devices. That should be fairly quick on your existing Mac user account, but could take a while on a new disposable one.

If you have some spare email addresses handy, you could even create a disposable AppleID for testing.


Also, what version of macOS are you using that it still has iTunes? And which iTunes version?
 

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,020
164
Norway
The thing is that I've never synced my calendars and contacts to iCloud, but always via USB.
Then again I've experienced that after a factory reset or a brand new iPad/iPhone, all those iCloud settings are on by default, so you really have to dig deep into the settings to turn it off and in the meantime I guess something might have been synced anyway. IMHO It's unlikely though, because I've had calendars pop up which have been made locally not long ago, but could they essentially be remnants of old iCloud-based calendars which I've since renamed (but can't remove)?

I'll give your suggestions a go and see what happens.
As for the versions: I'm on MacOS 10.13.6 (High Sierra) and iTunes 12.8.3.1.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,837
8,605
A sea of green
iCloud is really the only other "fetched from somewhere else" that seems plausible.

If you haven't checked the online iCloud stuff in a while, there's no way of telling what's there.

Whenever I setup a new device, I always turn off its internet connectivity before I tell it an AppleID. This gives me a chance to configure syncing and whatnot first.
 

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,020
164
Norway
Thanks for your suggestions which I've now tried.
There was no calendar data from before in my iCloud, so I proceeded by creating a few calendars and calendar-entries from both sides (Mac and iPhone) with both logged into my Apple ID and using iCloud for calendar storage. Things appeared to work as intended: when making a change (adding/removing/editing a calendar or calendar-entry) the change would be reflected on the other device.
But it appeared to have no impact on my long-since-deleted calendars from before, and I also noticed that the iCliud calendars appeared to be separated from the Mac-offline calendars, like two different "zones" working independantly from each other.

So having played around with this for a while I ended up by deleting all the iCloud calendars/entries and finally turning off iCloud for Calendar so I could get back to my regular setup.
(by the way, I had problems logging into icloud.com from a web browser (I tried multiple browsers, so I assume Apple's having a problem for the time being), but it worked fine from the Mac's "iCloud" system preference (or Calendar's settings) as well as the general settings on my iPhone)


It still appears as though the calendars are stored somewhere else than inside ~/Library/Calendars/ as now I also have a bunch of "left over" calendars from when I synced them up with iCloud:

Reminders(null)@p123.caldav.icloud.com
Work(null)@p123.caldav.icloud.com
Home(null)@p123.caldav.icloud.com


Those now show up in iTunes along with many other calendars, some of them repeated with the exact same calendar name (for instance "Reminders" which I have three calendars of, in iTunes, but in the Mac Calendar app I don't have any calendar with that name at all). Basically, the calenders I see in the iTunes "Info" section (whenever my iPhone is USB-attached to the Mac) is NOT a true reflection of neither what's on the Mac, nor what's on the iPhone (like now, when I've (through the iPhone Calendar app's "calendars" section) I've deleted all of the calendars.
Other calendars that I've deleted that seem to reappear apart from the ones I've already mentioned are mostly "Found in natural language" and "Siri found in apps". I think I may at some stage several years ago tried to rename one/several of those when I couldn't find any normal way of removing them, so perhaps the Mac is somewhat confused... ??!?!

So now that I've determined iCloud isn't to blame (and if something was "stuck" it should now have gotten unstuck because I've cleaned up and let it finish it's thing etc.) and old calendars still get "stuck" as shown in iTunes I'm wondering what's to blame.
Actually, forget that. ......if there a sure way to factory reset the Mac Calendar app so I can just start afresh and re-import my calendars into it I'll be more than happy :)
Since I've already tried "everything" I have a feeling there might be some background processes which I need to quit before deleting the various Calendar related files/folders. Maybe they're causing things to be cached?
Using the "Activity Monitor" app I've searched for anything "cal" or "sync" related and ended up force-quitting "CalendarAgent" and one of the sync related processes which I can't find now for some reason (?!?!??).
 

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,020
164
Norway
Some new info.....
I came across another sync related posting where there was talka bout the following folder:
~/Library/Application Support/SyncServices/

Since I had nothing to lose I first force-quit the following two processes within Activity Monitor:
syncdefaultsd
CalendarAgent


Then I deleted (actually I only renamed it, just in case..) the one and only file inside the abovementioned folder which is called "Local", and logged out of my Mac user, then logged back in again.

I don't know if this is a final solution, but it looks promising as a new iTunes USB-sync now properly reflects what the Mac Calendar app shows except there are two "Home" and two "Work" calendars (spelt exactly the same).
A new "Local" file was rebuilt (around 2 MB now instead of around 7 MB of before).

It seems this file might have something to do with the synchronized data. Does anyone reading have more details about it, and if I haven't done it correctly, is there a better way to reset it so as to reset the sync function that iTunes uses?

UPDATE: I may have something working now.... I'll report back after having tested it all out, but as this is all trial and error I would like to hear from people who know what they're doing and can tell me how to correctly reset the OSX Sync Services.
 
Last edited:

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,020
164
Norway
OK, I've made some progress and now have a better understanding of how things work (well, at least from a user's perspective as I'm no programmer or have any deep understanding of how MacOS works)....
Here's the thing: there are actually two separate things you need to decide on doing:

a) reset Calendar to its defaults
or
b) reset SyncServices to its defaults

Resetting the Calendar app
As long as the Calendar app works fine in MacOS I see no reason why it needs resetting.
The problems I've been having appear not related to Calendar itself as I first thought, but to a mismatched sync through iTunes.
But.... if you need or want to start all over with Calendar (reset it to its factory defaults) you also need to reset SyncServices (b).

Why?
Well, after resetting Calendar all looked fine here (my own calendars were gone, no entries and just a couple of default calenders to be seen), but after perhaps 30 seconds all of a sudden all my own calendars showed up and everything looked just like before!
Obviously this isn't what you want, so if you want to reset Calendar you have to do both steps (a) and (b).
So here's how you reset the Mac Calendar app to its defaults:

1) if you have any calendars and associated entries you want to keep, make sure you've made backups before proceeding as all this will be deleted:
- (Mac Calendar app), go to File-Export-Calendar archive which will back up everything in one file
- (Mac Calendar app), also highlight (click once) on a calendar you want to back up (i.e. "Home" as shown below), then go to File-Export-Export to back up just that calendar. Repeat the process by selecting the next calendar and export that in the same way as well. It might prove useful to back everything up using both methods.
Screen Shot 2022-06-13 at 20.50.51.png


2) Quit the Calendar app

3) Start Activity Monitor (found in your Mac's /Applications/Utilities/ folder) and in its search function type: cal

4) Double-click on where it says CalendarAgent.
Screen Shot 2022-06-13 at 20.56.41.png


5) This will bring up a new window.
Click on "Quit" in order to quit this process. A couple of seconds later you'll see that CalendarAgent has indeed been quit.
Screen Shot 2022-06-13 at 21.11.31.png

6) Now, delete the following files and folders:

LIBRARY folder
~/Library/Calendars/ (delete the entire folder)

CONTAINERS folder
~/Library/Containers/com.apple.CalendarAgent
~/Library/Containers/com.apple.CalendarNotification.CalNCService
~/Library/Containers/com.apple.iCal

PREFERENCES folder
~/Library/Preferences/com.apple.iCalExternalSync.plist
~/Library/Preferences/com.apple.iCal.plist


7) Next, delete the files/folders belonging to SyncServices (follow steps 1 and 2 in "Resetting SyncServices" below)

8) Empty the Mac trash

9) Log out from you Mac user

10) Log back in to your Mac user

11) Start the Calendar app. Everything should now be empty and factory-reset.
Screen Shot 2022-06-14 at 13.37.54.png



NOTE: I was expecting to see the following welcome window after having reset Calendar, but for some reason this rarely (but sometimes) happens after having deleted all those files. Does anyone know what I've missed out in order to get this welcome window to confirm that it's actually been factory reset? I'm pretty sure I've deleted all of the Calendar-related files and folders which will be rebuilt again as factory defaults.
screen-shot-2022-05-14-at-18-42-48-png.2006360


12) If you have any calendar information available that you previously backed up, now is the time to import those into the Calendar app again.

13) To fully repair things so you can synchronize Calendar (and Contacts) with an iOS device (iPad/iPhone etc.) you need to reset the synchronization files, so proceed with all the steps below ("Resetting SyncServices").






Resetting SyncServices
Here's what caused and solved my problem. First, it seems the problem of old calendars re-appearing etc. whenever I tried to sync an iPad or iPhone with the Mac was related to sync mismatch issues. So resetting this appeared to get the calendars and contact information in sync between the Mac and those iOS devices again. This will probably also repair any sync mismatch with Contacts as well.

1) Make sure iTunes is not running (if so, quit it)

2) Delete the following files and folders:

APPLICATION SUPPORT folder
~/Library/Application Support/SyncServices/ (delete the entire folder)

PREFERENCES folder
~/Library/Preferences/com.apple.syncserver.plist
~/Library/Preferences/com.apple.iCalExternalSync.plist

PREFERENCES Byhost folder
~/Library/Preferences/ByHost/com.apple.syncservices.ConflictResolver.8121C514-017A-5840-9288-92E40350D374.plist
~/Library/Preferences/ByHost/com.apple.syncservices.8121C514-017A-5840-9288-92E40350D374.plist
~/Library/Preferences/ByHost/com.apple.AddressBook.sync.8121C514-017A-5840-9288-92E40350D374.plist


(NOTE: the numbers in these files are likely different than in this example!
Just look for (or use the Finder's search function) the following within the ~/Library/Preferences/ByHost/ folder:

com.apple.syncservices.ConflictResolver
com.apple.syncservices
com.apple.AddressBook.sync


3)
empty the Mac trash

4) Log out from you Mac user

5) Log back in to your Mac user

6) Attach the iOS device (iPad, iPhone etc.) to the Mac with a USB cable

7) Open iTunes and click on the iOS device icon to access it
Screen Shot 2022-06-14 at 09.28.06.png


8) Go to the "Info" section
Screen Shot 2022-06-14 at 09.28.34.png


9) At this stage it might be a good idea to start fresh and sync from the Mac as the source.
Enable "Sync Calendars" (and if you want) "Sync Contacts".
screen-shot-2022-05-18-at-09-31-49-png.2006367

Scroll down to "Advanced" where you see "Replace information on this iPad" (or iPhone) and select "Calendars" (and "Contacts" if you'll be syncing those as well).
Screen Shot 2022-06-14 at 09.29.08.png


10) Click the "Apply" button to start synchronizing the iOS device with the Mac. When done everything should be in sync. You may want to test it out properly by creating/editing and deleting new calendars and entries on both platforms (iOS device and Mac) to see if the changes are taken over to the other device.


I think that's it. Please let me know if I've missed anything :)
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.