0

I'm currently setting up a few OS X clients and servers and frequently need to open/edit .plist files. Annoyingly OS X compiles these plist files into a binary format, presumably to speed up reading them for performance reasons, which is great except I need to convert them back to xml every time I need to open them which is more important to me than a insignificant performance boost.

So I have to either:

  1. Use Plist editor - I don't like it and it requires Xcode to be installed - not always feasible on a client machine.
  2. Convert them using plutil: plutil -convert xml1 file.plist - which is a PITA.

Is there a way of stopping OS X from converting the nice XML plists to the Devils' binary format?

Jon Rhoades
  • 4,987
  • 3
  • 31
  • 48

1 Answers1

3

I think the format of a property list file is completely determined by the program that creates/updates the file. The Cocoa property list serialization methods and those of Core Foundation all take a format option that lets the program specify either “XML” or “binary”; there is no value like “use some externally specified default”. Programs could conceivably do their own defaulting based on some centralized setting, but I am not aware of any such setting (of course it could just be undocumented; the point is that it would still be limited to only the applications that adopted such a “manual defaulting” convention).


PlistBuddy is a flexible and mostly scriptable property list editor (e.g. defaults will only access/modify values at the “top level” of the property list, but PlistBuddy can access/modify values at any arbitrary depth). It is available at /usr/libexec/PlistBuddy on 10.5 and later. It was not bundled with the system on 10.4, but you can usually find it as one of /Library/Receipts/*/Contents/Resources/PlistBuddy (e.g. /Library/Receipts/iTunesX.pkg/Contents/Resources/PlistBuddy).

E.g.

  • inspect a property list file

    PlistBuddy -c print /path/to/some/plist/file
    
  • clear out (or create) a plist file and set CFBundleIdentifier to com.apple.plistbuddy

    PlistBuddy -c 'clear dict' \
               -c 'add :CFBundleIdentifier string' \
               -c 'set :CFBundleIdentifier com.apple.plistbuddy' \
        /path/to/some/plist/file
    

You could also use osascript to run commands from System Events’ “Property List Suite”. It is certainly not as convenient to run from a shell command line, but would be fine for more automated inspections and modifications (i.e. done by a script). The commands from this suite offer write access on 10.5 and later (10.4 was read-only).

Chris Johnsen
  • 1,688
  • 1
  • 15
  • 18