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
- The formats
- The tool
- The Plist library
- The object table
2The tool
- Overview: the format, size and, for binary plists, the object count and the sizes in the trailer.
- Structure: the plist as a tree. Dictionaries show their keys sorted; File order shows them as stored. Click a key or value to copy it (data is copied as base64).
- As XML: the plist written as XML, also for binary input.
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.
| Method | Returns | What it does |
| Plist.decode(input) | a value | Reads 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) | Uint8Array | Writes a value as an XML plist (UTF-8). Keys whose value is undefined are left out. |
| Plist.toXml(value) | string | The same XML as encode, as text, indented with tabs like plutil. |
| Plist.convertToXml(input, options) | string | Any 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 Plist | The 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
| Plist | JavaScript (decode) | Written by encode as |
| dict | object | any other object |
| array, set | array | array |
| string | string | string |
| integer | number, or BigInt beyond 253 | an integer number or a BigInt |
| real | number | a number with a fraction |
| true, false | boolean | boolean |
| date | Date | Date |
| data | Uint8Array | Uint8Array |
| 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 / property | What it is |
| format | "binary" or "xml". |
| meta | { format: "xml" } or, for binary plists, { format: "binary", version, objectCount, offsetSize, refSize, topObject }. |
| objectCount, topObject | How many objects there are, and the index of the root. |
| object(index) | A record (below). |
| decode() | The plain values, as Plist.decode gives them. |
| Record | Fields |
| 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());