Deleting user defaults under Mac OS X 10.10.3

Since a short time (I (guess* since Mac OS X 10.10.2) I was able to clear my settings under NSUserDefaults via

defaults delete ~/Library/Preference/<my app>.plist

But all of a sudden it does not work and my settings seem to be super-persistent. I also manually cleared anything under “Saved Settings” and issued the above command for “Containers” (though sandboxing was turned off for testing anyway).

What else can hold my settings? I guess the next reboot might clear it but I want to avoid rebooting in the future.

PS The settings did even survive a reboot :-(


Solution 1:

First, when using defaults, you must leave off the .plist from the filename -- it always adds that, so if you also supply it defaults will try to delete "<my app>.plist.plist".

Second, I think that when you specify the full path to the preference file you bypass cfprefsd, which (among other things) caches recently-used preferences. You should either just use defaults delete <my app>, or run killall cfprefsd before deleting the preferences (but after quitting the app).

Note that if the app is sandboxed, defaults is the wrong way to delete the preferences -- just kill cfprefsd, then use rm to delete either the app's entire sandbox container (rm ~/Library/Containers/<my app>) or just its preference file (rm ~/Library/Containers/<my app>/Data/Library/Preferences/<my app>.plist)

Solution 2:

Check in ~/Library/Containers/.

I think sandboxed (App Store) apps have to store their stuff there now.