Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting plist file does not reset app on macOS 10.9+

While developing a Cocoa application on 10.9, I have noticed that if I go to ~/Library/Preferences and delete the plist file for my app (to reset it), on the next build-and-run, the app behaves as if the plist file had never been deleted at all.

It took me a long time to track down why this happens and I did not see a question/answer about it on SO, so I'm writing this question and answering it myself to help others.

like image 399
Bryan Avatar asked Oct 10 '13 18:10

Bryan


People also ask

Can I delete plist files on Mac?

Preference PLIST files are harmless and its totally fine to delete them. However, not all PLIST files must be treated the same as the preferences of applications. Mostly, PLIST files in the preference folder won't create any conflict with the main application after deleting.


2 Answers

On 10.9, the system is doing some more robust "caching" of preferences. After deleting the plist file, I fired up Activity Monitor and force-killed the "cfprefsd" process. Be careful: there are multiple processes with this name running and you only want to kill the one running under your own user; do not kill the one running as root.

Doing this seems to flush the preferences cache and on the next run of my app, I get a pristine start-from-scratch launch.

Edit: As reported below, using defaults delete [your bundle identifier] at the command line also appears to eliminate the caching issue. I've had mixed success with this.

like image 176
Bryan Avatar answered Sep 17 '22 20:09

Bryan


I found out that killing the user process cfprefsd will reflush the cache, so your changes will be kept

killall -u $USER cfprefsd

like image 40
Pencilcheck Avatar answered Sep 21 '22 20:09

Pencilcheck