Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.