Preferential Treatment - Test XML preference files

Jun 23, '04 10:00:00AM

Contributed by: robg

Preferential Treatment iconThe macosxhints Rating:
9 of 10
[Score: 9 out of 10]

One of the subtle causes of OS X crashes and behavioral oddities is corruption in an XML preferences file. Normally, discovering this corruption is a bit of a trial and error process -- you notice an app is misbehaving, so you trash its prefs and see if things get better. Apple, however, included a Unix tool (as of 10.2 and newer) to help automate the process -- plutil. Using the Terminal, you can check your user's Preference files, for instance, by typing sudo plutil -s ~/Library/Preferences/*.plist.

This will generate a report showing which, if any, preference files have syntax errors. It's run as root because some preference files (such as TechTool4's) are owned by root, due to the way the apps run). The -s switch tells plutil to suppress output on successful files (those that test OK), leaving just the troublesome files in the output report. At that point, you can delete, move, or try to fix the flagged files (plutil was covered in more detail in this previous hint).

While this is handy, not everyone loves the Terminal (shocking, I know!), which is where Preferential Treatment comes in. This AppleScript Studio application wraps a nice GUI around plutil, and it lets you easily test both the user-level and system-level preference files. The output is an easy-to-read table showing the filename and a description of the problem.

Advanced users can even edit the preferences to add additional preference directories, change the script that's run, and modify the application used to edit a corrupt preference file (which you do by double-clicking any item in the output). A handy smart button reveals flagged files in the Finder, moves them to the trash, or lets you choose an app with which to open the file. There's a button to give the app admin privileges, too, so it can test those root-owned user and system-level files.

If you're handy in the Terminal, you probably won't need Preferential Treatment ... but if you'd rather have a nice GUI wrapper and an easy way to test all your XML preference files, give it a look.

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040623070038472