← Property lists
Plist·Guide
All tools

Property lists

Property lists are Apple's format for settings and structured data: Info.plist in every app, entitlements, provisioning profiles, privacy manifests (.xcprivacy), preferences under Library/Preferences, and the messages iOS devices exchange over USB. The tool reads the XML and binary forms in your browser; the same code is a library you can use in your own pages.

Contents

  1. The formats
  2. The tool
  3. The Plist library
  4. The object table

1The formats

A plist holds one value: a dictionary (string keys), an array, a string, an integer, a real, a boolean, a date or data (bytes). Containers nest.

bplist008 bytes
objectsmarker byte + payload
offset tablewhere each object starts
trailer32 bytes: sizes, count, top object

Dates are seconds since 2001-01-01 UTC. Strings are ASCII or UTF-16 big-endian.

2The tool

Other tools hand plists to the tool: the IPA tool, the iOS Device page and the SQLite tool (for plist blobs).

3The Plist library

lib/plist.js is a JavaScript module with no dependencies and no user interface. It exports Plist: static methods for whole files, and instances for an opened plist's object table (next section).

import { Plist } from "../lib/plist.js";

const bytes = new Uint8Array(await file.arrayBuffer());
const info = Plist.decode(bytes);
console.log(info.CFBundleIdentifier, info.CFBundleShortVersionString);

info.CFBundleDisplayName = "Patched";
const xmlBytes = Plist.encode(info);   // Uint8Array with an XML plist

It also loads in a module Web Worker and in jsc. Reading XML plists needs the browser's DOMParser, so there it works only in a page; binary plists and writing work everywhere.

An input is an ArrayBuffer, a Uint8Array (or another typed array) or a string with XML.

MethodReturnsWhat it does
Plist.decode(input)a valueReads a binary or XML plist into plain JavaScript values (see the table below). Objects a binary plist shares are built once; a reference cycle becomes null.
Plist.encode(value)Uint8ArrayWrites a value as an XML plist (UTF-8). Keys whose value is undefined are left out.
Plist.toXml(value)stringThe same XML as encode, as text, indented with tabs like plutil.
Plist.convertToXml(input, options)stringAny plist as XML, keeping every type as stored (a whole real stays <real>, a set becomes an array, a cycle a comment), like plutil -convert xml1. options.maxChars (8 MB) and options.maxDepth (512) bound the output. Also takes a plist from open.
Plist.open(input)a PlistThe exact structure, for viewers and keyed archives (next section). Throws with a readable message for OpenStep and unknown files.
Plist.detect(input)string or null"binary", "xml", "openstep" or null.

Values

PlistJavaScript (decode)Written by encode as
dictobjectany other object
array, setarrayarray
stringstringstring
integernumber, or BigInt beyond 253an integer number or a BigInt
realnumbera number with a fraction
true, falsebooleanboolean
dateDateDate
dataUint8ArrayUint8Array
UID (binary only){ uid: n }{ uid: n } becomes <dict><key>CF$UID</key>…
The library writes XML only. Every Apple API that reads plists accepts XML, so a binary plist you change can be saved as XML and still work in an app or on a device.

4The object table

A binary plist is a table of numbered objects that refer to each other; Plist.open() gives that table, and presents an XML plist the same way, so one piece of code handles both. Objects are decoded only when asked for, so a huge plist opens at once.

Method / propertyWhat it is
format"binary" or "xml".
meta{ format: "xml" } or, for binary plists, { format: "binary", version, objectCount, offsetSize, refSize, topObject }.
objectCount, topObjectHow many objects there are, and the index of the root.
object(index)A record (below).
decode()The plain values, as Plist.decode gives them.
RecordFields
string, int, real, bool, date, data, uid, null, fill{ type, value }. Dates are Unix milliseconds, data is a Uint8Array, an int is a number or a BigInt.
array, set{ type, refs }: the indexes of the elements.
dict{ type, keys, values }: the indexes of the key strings and of the values.

In a binary plist one object can be referenced from several places, and even from inside itself (keyed archives do both), so code that walks the table should remember the containers it is inside.

const table = Plist.open(bytes);
function walk(index, path, inside) {
	const record = table.object(index);
	if (inside.has(index)) {
		return console.log(path, "(cycle)");
	}
	const below = new Set(inside).add(index);
	if (record.type === "dict") {
		record.keys.forEach((key, position) => walk(record.values[position], path + "/" + table.object(key).value, below));
	} else if (record.type === "array" || record.type === "set") {
		record.refs.forEach((ref, position) => walk(ref, path + "/" + position, below));
	} else {
		console.log(path, record.type, record.value);
	}
}
walk(table.topObject, "", new Set());