How-to: Replace preference files in Mavericks

Something many people do, myself included, is copy an application’s preferences file—either from one Mac to another (as a quick way of getting an app configured to my liking) or to replace a damaged/lost preferences file using a Time Machine backup. Until recently, this process was really simple: quit the app in question, trash the existing prefs file, insert the new prefs file, launch app.

Enter OS X 10.9, aka Mavericks, aka “the easy prefs copy killer.” Apple has made changes to the way the preferences system works in Mavericks, and one casualty of those changes is the easy replacement of an application’s preferences file. A brief bit of before-and-after, and then we’ll get to the fix—or just click the Read More link to jump right to the fix.

In prior versions of OS X, preferences files were always read by the application at launch. So as long as the app wasn’t running, if you replaced its preference file, it would read the new file the next time you launched the program.

In Mavericks, preferences are managed by a background daemon, cfprefsd. This service reads the preferences file once, when you first run the app. It then (I believe) receives notifications if you change the program’s settings while the program is running, and then writes them to the actual preferences file at certain points in time. But cfprefsd always has a copy of those settings in its cache, and that’s what the app gets when it checks its settings. (This reduces hard disk access, which is important in conserving battery life in laptops.)

Here’s the important bit: After you’ve launched an app once, it seems that any subsequent launches also get their preferences from cfprefsd. So if you try the old “replace the prefs while the app isn’t running” trick, you’ll be quite surprised to find that your program launches with its previous settings. It will do this even if you simply delete (via Finder) the old prefs file!

So how do you get around this aggressive caching of preference files?

I’m aware of two solutions, though there may be others (please comment, if you know of a better way).

Method One:

  1. Quit the app, and make sure it is not set to run at login.
  2. Delete the app’s prefs file (typically in ~/Library/Preferences, for non-sandboxed applications).
  3. Logout.
  4. Login.
  5. Copy the prefs file you want to use into its home.
  6. Launch the app.

Method Two:

  1. Quit the app, leaving the ‘bad’ prefs file in place.
  2. Open Terminal, paste the following, and press Return: defaults delete com.COMPANY_ID.APP_ID. Note that COMPANY_ID and APP_ID are taken from the name of the app’s preferences file. Using our own Moom for example, the preferences file is named com.manytricks.Moom.plist, so the command would be defaults delete com.manytricks.Moom.
  3. Copy the prefs file you want to use into the ~/Library/Preferences folder.
  4. Launch the app.
  5. I’ve tested both of these methods and found them to work, but would love to discover there’s an easier solution.

    Net net, if you want to replace prefs files in Mavericks, it’s now more complicated than it used to be…but it is still possible.

5 Responses to “How-to: Replace preference files in Mavericks”

  1. Rich Talley says:

    1. Quit the app and replace its prefs file with the one you want to use.
    2. In Terminal, use this command:
    defaults read ~/Library/Preferences/com.COMPANY_ID.APP_ID

    It’s not specified in the man page for defaults, but the read option re-caches the prefs.

    • Rob Griffiths says:

      I swear I tried that, but it failed … I imagine I must’ve done something wrong, though, so I’ll try it again in a bit. Thanks for the tip!

      -rob.

  2. Steve says:

    Hey Rob,

    Quit the app then run “killall cfprefsd” in Terminal which will flush all settings to plists and relaunch the cfprefsd agent. All apps trying to access cfprefs during this time will block.
    Now restart the app and it will read the new plist file.
    This is what I have to do in SwitchUp. I’ve done extensive testing and it’s a stable solution.

    Steve

  3. Dan says:

    killall cfprefsd is the only thing that worked for me on 10.9.3

  4. Daniele says:

    Thank you.

    The following method worked for resetting FCPX preferences.

    1. Quit the app and replace its prefs file:
    ~/Library/Preferences/com.apple.FinalCut.plist

    2. In Terminal, use this command:
    defaults read ~/Library/Preferences/com.apple.FinalCut.plist

Leave a Reply