macOS property list files

From Free Pascal wiki

This article applies to macOS only.

See also: Multiplatform Programming Guide


A property list is a representation of a hierarchy of objects that can be stored in the file system and reconstituted later. Property lists give applications a lightweight and portable way to store small amounts of data. They are hierarchies of data made from specific types of objects—they are, in effect, an object graph. Property lists are easy to create programmatically and are even easier to serialize into a representation that is persistent. Applications can later read the static representation back into memory and recreate the original hierarchy of objects. Both Cocoa Foundation and Core Foundation have APIs related to property list serialization and deserialization.

Data types

Property lists consist only of certain types of data: dictionaries, arrays, strings, numbers (integer and float), dates, binary data, and Boolean values. Dictionaries and arrays are special types because they are collections; they can contain one or multiple data types, including other dictionaries and arrays. This hierarchical nesting of objects creates a graph of objects. The abstract data types have corresponding Foundation classes, Core Foundation types, and XML elements for collection objects and value objects.

Data formats

You can write property lists out in XML, JSON and binary formats. The binary format is much more compact than the XML version and thus more efficient. It is recommended for most situations. However, you can manually edit an XML property list if you ever need to. You can also edit a JSON file because it is just concatenated text and much less verbose than pure XML. Property list files have the filename extension of plist.

You should not use property lists to store large, complex graphs of objects, especially when the objects have variable mutability settings. And you cannot use property lists to store objects that are not supported by the architecture, such as model objects. For these cases, use archiving instead. Although property lists can include NSData objects, it’s best to not use data objects in property lists to hold large amounts of binary data.

XML, JSON or binary?

The property list file type can be identified using the file command on macOS:

 $ file org.sentry.picinfo.plist
 org.sentry.picinfo.plist: Apple binary property list           // binary format
 $ file org.sentry.picinfo.plist
 org.sentry.picinfo.plist: XML 1.0 document text, ASCII text    // XML format
 $ file org.sentry.picinfo.plist
 org.sentry.picinfo.plist: ASCII text, with no line terminators // JSON format

Converting between the different plist formats can be performed using the plutil command on macOS:

 $ plutil -convert binary1 org.sentry.picinfo.plist   // convert to binary format
 $ plutil -convert xml1 org.sentry.picinfo.plist      // convert to XML format
 $ plutil -convert json org.sentry.picinfo.plist      // convert to JSON format

External links