# 属性列表

属性列表（property list），通常称为 plist，是 Apple 操作系统和编程框架中使用的一种层级数据结构，用于将少量数据——通常是由字符串、数字、日期和二进制数据组成的字典和数组——序列化到文件中，之后可以再读回内存并重新构建为对象。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> 属性列表为应用程序提供了一种轻量且可移植的方式来存储少量持久数据，在 macOS 和 iOS 上被系统级地用于偏好设置、应用程序配置和包元数据。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup><sup> • </sup><sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 由特定允许类型的对象构成的层级结构，实际上是一个对象图，可序列化到磁盘并在之后重新构建<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> |
| 允许的类型 | 字典、数组、字符串、数字（整数和浮点数）、日期、二进制数据和布尔值；图中的每个对象都必须是这些类型之一，属性列表才有效<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> |
| 文件格式 | XML、二进制，以及继承自 OpenStep 的“老式”ASCII 格式；老式序列化 API 为只读<sup>[3](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)</sup> |
| 文件扩展名 | `plist`<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> |
| 二进制文件头 | 二进制 plist 以魔数 `bplist00` 开头；Apple 框架内部还存在未公开的 `bplist15` 和 `bplist16` 变体<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup> |
| 序列化 API | Cocoa 中的 `NSPropertyListSerialization` 以及 Core Foundation 中的 `CFPropertyListRef` 不透明类型<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> |
| 最广为人知的用途 | 每个打包的可执行文件（应用、框架、插件）都携带的 `Info.plist` 信息属性列表<sup>[4](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html)</sup> |

## 数据模型

属性列表将数据组织为命名值和值列表。在 Core Foundation 术语中，构建块是 CFString、CFNumber、CFBoolean、CFDate、CFData、CFArray 和 CFDictionary；在 Cocoa 中，对应的类是 NSString、NSNumber、NSDate、NSData、NSArray 和 NSDictionary，同时也支持 Foundation 类的可变版本。<sup>[5](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPropertyLists/CFPropertyLists.html)</sup><sup> • </sup><sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> 只有当图中的每个对象都是这些属性列表对象之一时，属性列表才有效；架构之外的对象（如模型对象）不能存储，建议改用归档。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup>

序列化属性列表的根几乎总是字典或数组。例如，在 XML 属性列表中，信息属性列表的根 XML 节点是一个字典，其键和值描述该包。<sup>[4](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html)</sup>

## 文件格式

**XML。** XML 表示遵循 Apple 发布的[文档类型定义](https://www.edgepedia.org/zh/document-type-definition)，在每个 XML plist 顶部声明为 `<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`，并带有单一根元素 `<plist version="1.0">`。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup> 值使用元素标签书写，如 `<string>`、`<integer>`、`<real>`、`<date>`、`<data>`、`<true/>`、`<false/>`、`<array>` 和 `<dict>`；日期以 [ISO 8601](https://www.edgepedia.org/zh/iso-8601) 格式存储。<sup>[6](https://apple.lib.utah.edu/configuration-profiles-part-i/)</sup> XML plist 是人类可读的，可以手动编辑，这使其比二进制替代方案更具可移植性。<sup>[3](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)</sup> 英国国家档案馆的 PRONOM 注册处将 XML 属性列表记录为一种独立格式，扩展名为 `plist`，用于 OS X、iOS、NeXTSTEP 和 GNUstep 框架中存储序列化对象。<sup>[7](https://pronom.nationalarchives.gov.uk/fmt/979)</sup>

**二进制。** 二进制格式比 XML 版本紧凑得多，因此更高效；Apple 在大多数情况下推荐使用它，二进制 plist 需要更少的内存，读写速度也比 XML 快得多。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup><sup> • </sup><sup>[3](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)</sup> 二进制文件以文件头 `bplist00` 开头。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup> 二进制格式没有官方规范，但 Apple 的实现以开源形式发布在 `CFBinaryPList.c` 中，其注释详细描述了结构，足以支持替代实现。<sup>[8](https://www.metaobject.com/downloads/Misc/CocoaOptimization.pdf)</sup> 另外两个变体——`bplist15`（CoreFoundation 内部使用）和 `bplist16`（几乎专用于通过 XPC 进行的 [Objective-C](https://www.edgepedia.org/zh/objective-c) 远程调用）——除了该源文件中的注释外没有文档；1+ 格式增加了 UUID、URL、UTF-8 字符串、集合、有序集合和 NULL 等类型。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup>

**老式 ASCII。** NeXTstep 和 OpenStep 文本格式使用等号表示属性-值绑定，使用花括号表示层级。macOS API 仍可加载它，但该格式的序列化 API 为只读。<sup>[3](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)</sup> GNUstep——OpenStep Foundation 的自由实现——继续使用这种经典格式作为其原生表示，在 Windows 等某些平台上 XML 支持有限。<sup>[9](https://mediawiki.gnustep.org/index.php/Property_Lists)</sup>

**JSON。** 属性列表也可以序列化为 JSON，JSON 序列化的 plist 在 Apple 基于 HTTP 的协议中并不少见；`plutil` 工具可以用 `-convert json` 将 plist 转换为 JSON。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup>

## 序列化 API

在 Cocoa 中，`NSPropertyListSerialization` 类在属性列表和多种序列化格式之间进行转换；其方法生成或消费 `NSData` 对象，然后可以写入文件系统（例如使用 `writeToFile:atomically:`）并读回内存。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup><sup> • </sup><sup>[10](https://developer.apple.com/documentation/foundation/propertylistserialization?language=obj_8)</sup> 反序列化时，调用方指定可变性选项，控制重建的对象是不可变的还是具有可变容器。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> 在 Core Foundation 中，等效设施围绕 `CFPropertyListRef` 不透明类型构建。<sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> 属性列表对象在两个框架之间是 toll-free bridged 的。<sup>[10](https://developer.apple.com/documentation/foundation/propertylistserialization?language=obj_8)</sup>

在 Apple 平台之外，Python 标准库的 `plistlib` 模块可以读写二进制和 XML plist 文件；二进制格式支持在 Python 3.4 中加入，对二进制 plist 中 NSKeyedArchiver 使用的 UID 标记的支持在 Python 3.8 中加入。<sup>[11](https://docs.python.org/3.14/library/plistlib.html)</sup>

## Apple 平台上的用途

**Info.plist。** 按照惯例，信息属性列表文件名为 `Info.plist`，区分大小写，首字母大写 `I`。在 iOS 应用中，该文件位于包目录的顶层；在 macOS 包中，它位于包的 `Contents` 目录中。所有打包的可执行文件——包括插件、框架和应用——都应有一个，系统读取其键和值以了解应用的配置方式。<sup>[4](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html)</sup> Launch Services——决定哪个应用程序打开给定文档或 URL 的子系统——从应用的 `Info.plist` 获取所需信息，对于单文件应用则从资源分支中的 `'plst'` 资源获取。<sup>[12](https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html)</sup>

**其他包属性列表。** Xcode 还管理用于授权（entitlements）的属性列表文件（记录在扩展名为 `.entitlements` 的文件中）和隐私清单（名为 `PrivacyInfo.xcprivacy` 的属性列表文件，描述应用或第三方 SDK 收集的数据及其使用的需要说明使用理由的 API）。<sup>[13](https://developer.apple.com/documentation/bundleresources/entitlements?language=_1)</sup><sup> • </sup><sup>[14](https://developer.apple.com/documentation/bundleresources/adding-a-privacy-manifest-to-your-app-or-third-party-sdk?changes=_8)</sup> Xcode 跟踪常见属性列表文件的模式，并在其属性列表编辑器中添加键时为该键设置正确的类型。<sup>[15](https://developer.apple.com/documentation/xcode/editing-property-list-files)</sup>

**偏好设置与配置。** 用户和应用偏好设置使用属性列表，macOS 的 `defaults` 命令可以将偏好设置导出为 plist 文件。<sup>[5](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPropertyLists/CFPropertyLists.html)</sup><sup> • </sup><sup>[6](https://apple.lib.utah.edu/configuration-profiles-part-i/)</sup> 交付给 Mac 的配置描述文件同样以 XML 属性列表的形式构建。<sup>[6](https://apple.lib.utah.edu/configuration-profiles-part-i/)</sup>

## 工具与实用指南

`plutil` 实用工具于 OS X 10.2 引入，用于检查 plist 语法并在格式之间转换文件（`plutil -convert xml1`、`-convert binary1`、`-convert json`）；它还可以通过 `-insert`、`-replace` 和 `-remove` 执行基本编辑，`PlistBuddy(8)` 提供了交互式替代方案。<sup>[16](https://dlib.hust.edu.vn/bitstream/HUST/25373/1/OER000003349.pdf)</sup><sup> • </sup><sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup> Apple 的文档不建议手动编辑属性列表文件，因为它们是 XML 文件，建议改用 Xcode 属性列表编辑器。<sup>[4](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html)</sup>

Apple 关于适用范围的指导在其文档中是一致的：属性列表适合主要由字符串和数字组成的数据，即使允许使用 `NSData` 对象，在处理大块二进制数据时也非常低效。<sup>[5](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPropertyLists/CFPropertyLists.html)</sup><sup> • </sup><sup>[1](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)</sup> 对于相对较小的属性列表，XML 的优势超过了二进制的速度和紧凑性；对于大型数据集，二进制 plist、键控归档或自定义格式是更好的选择。<sup>[3](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)</sup>

## 历史

属性列表是 NeXTSTEP 的遗产，当时使用纯文本格式；Apple 后来随 OS X 引入了基于 XML 的格式和二进制 plist 格式。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup><sup> • </sup><sup>[16](https://dlib.hust.edu.vn/bitstream/HUST/25373/1/OER000003349.pdf)</sup> 该格式在 macOS 和 iOS 中仍然处于核心地位：launchd 等系统守护进程通过 `/System/Library/LaunchDaemons` 等目录中的属性列表文件进行配置，二进制格式作为基于键/值信息的文件格式在全系统范围内使用。<sup>[2](https://newosxbook.com/bonus/bplist.pdf)</sup>

## References

1. [Property list, Apple Developer Documentation Archive (DevPedia-CocoaCore)](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html)
2. [Interlude: Property Lists (bplist), *MacOS and iOS Internals*](https://newosxbook.com/bonus/bplist.pdf)
3. [Property List Programming Guide, Apple (2008 archive copy)](https://leopard-adc.pepas.com/documentation/Cocoa/Conceptual/PropertyLists/PropertyLists.pdf)
4. [About Information Property List Files, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html)
5. [Introduction to Property List Programming Topics for Core Foundation, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPropertyLists/CFPropertyLists.html)
6. [Configuration Profiles In-depth, Part I, Marriott Library, University of Utah](https://apple.lib.utah.edu/configuration-profiles-part-i/)
7. [XML Property List, PRONOM, The National Archives (UK), fmt/979](https://pronom.nationalarchives.gov.uk/fmt/979)
8. [Fun with Property Lists, *Cocoa Optimization* (Section 12.2)](https://www.metaobject.com/downloads/Misc/CocoaOptimization.pdf)
9. [Property Lists, GNUstepWiki](https://mediawiki.gnustep.org/index.php/Property_Lists)
10. [PropertyListSerialization, Apple Developer Documentation](https://developer.apple.com/documentation/foundation/propertylistserialization?language=obj_8)
11. [plistlib — Generate and parse Apple .plist files, Python 3 documentation](https://docs.python.org/3.14/library/plistlib.html)
12. [Launch Services Concepts, Apple Developer Documentation Archive](https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html)
13. [Entitlements, Apple Developer Documentation](https://developer.apple.com/documentation/bundleresources/entitlements?language=_1)
14. [Adding a privacy manifest to your app or third-party SDK, Apple Developer Documentation](https://developer.apple.com/documentation/bundleresources/adding-a-privacy-manifest-to-your-app-or-third-party-sdk?changes=_8)
15. [Editing property list files, Apple Developer Documentation](https://developer.apple.com/documentation/xcode/editing-property-list-files)
16. [Property lists chapter, macOS/iOS development text (HUST digital library copy)](https://dlib.hust.edu.vn/bitstream/HUST/25373/1/OER000003349.pdf)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Data formats and serialization

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/property-list

English original: https://www.edgepedia.org/property-list
