Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to programaticly edit a plist (rfc?)

Hello,

I have need to have a script I'm writing edit .plist files. Is there an RFC somewhere that covers the markup of .plists? anyone want to point me at what I should do to write one of these myself in plaintext?

Thanks.

-- James

Posted on Oct 25, 2006 8:21 AM

Reply
Question marked as Best reply

Posted on Oct 25, 2006 8:50 AM

Hi James,

HAve a look at Late Night Software's "Property List Tool" ( http://www.latenightsw.com/freeware/PListTools/index.html). It is very easy to use and quite reliable, with no or minimal learning curve.

Hope this helps!
3 replies

Oct 25, 2006 8:56 AM in response to jbarros

James,

Property list files are a specific type of XML document although in Tiger they are often stored in a binary format. You may want to look at Apple's Property List Programming Guide or Apple's DTD (Document Type Definition) for property lists (if you understand how to read a DTD).

The "defaults" command line tool can be used to read/write plist files as long as you don't have to deal with complex nested structures. So it may be useful in your script.

There's also a command line utility that comes embedded inside some of Apple's installers called PlistBuddy. You probably have some copies of this utility inside some of the installer receipts left behind in your /Library/Receipts folder. Executing PlistBuddy with a "-h" option will print out some usage information. For example:
<pre>
/Library/Receipts/SomePackageName.pkg/Contents/Resources/PlistBuddy -h
</pre>
The defaults command can access a property list file either as an XML text file or as a binary file... I'm not sure about PlistBuddy as I've never had a reason to use it.

If you have installed the Xcode Tools you'll also have Property List Editor (in /Developer/Applications/Utilities). Property List Editor is a GUI app that you can use to read/write plist files. It may be useful if you need to tinker with a plist file interactively, but it's probably not much use for scripting.

You can also use the "plutil" command line tool, if needed, which allows you to convert a binary plist file into an XML text file. You can then manipulate the text file with other text processing tools and use plutil again to convert back to binary.

If you need to work with complex or deeply nested data within the plist file then the defaults command may not be capable of doing it. You could potentially write a Cocoa tool that makes use of an NSDictionary/NSMutableDictionary to manipulate the plist data. The NSDictionary class in Cocoa makes it very easy to read/write a property list file with a single line of code. Once you've read the plist file into an NSDictionary you can use all the various class/instance methods to manipulate the dictionaries structure and data.

Steve

how to programaticly edit a plist (rfc?)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.