plist-cil 1.50.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package plist-cil --version 1.50.0
NuGet\Install-Package plist-cil -Version 1.50.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="plist-cil" Version="1.50.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add plist-cil --version 1.50.0
#r "nuget: plist-cil, 1.50.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install plist-cil as a Cake Addin
#addin nuget:?package=plist-cil&version=1.50.0

// Install plist-cil as a Cake Tool
#tool nuget:?package=plist-cil&version=1.50.0

plist-cil - A C# library for working with property lists

Build Status

This library enables .NET (CLR) applications to handle property lists of various formats. It is mostly based on dd-plist for Java. And as it, this is licensed under the terms of the MIT license.

Property lists are files used to store user settings and serialized objects. They originate from the NeXTSTEP programming environment and are now a basic part of thhe Cocoa framework (macOS and iOS) as well as the GNUstep framework.

Features

  • Read / write property lists from / to files, streams or byte arrays
  • Convert between property lists formats
  • Property list contents are provided as objects from the NeXTSTEP environment (NSDictionary, NSArray, NSString, etc.)
  • Serialie native .NET data structures to property list objects
  • Deserialize from property list objects to native .NET data structures

Supported formats

  • Cocoa XML
  • Cocoa Binary (v0)
  • Cocoa / NeXTSTEP / GNUstep ASCII

Requirements

.NET Framework 4.0, Mono or .NET Core. Targets .NET Framework 4.0, .NET Framework 4.5, .NET Standard 1.3, .NET Standard 1.4 and .NET Standard 1.6 so it should be compatible with Mono, Xamarin.iOS, Xamarin.Mac, UWP, etc. If you find an incompatibility, please create an issue.

Download

The latest releases can be downloaded here.

NuGet support

You can download the NuGet package directly from the release page or from the NuGet Gallery or from here.

Help

The API documentation is included in the download.

When you encounter a bug please report it by on the issue tracker.

Usage examples

Reading

Parsing can be done with the PropertyListParser class. You can feed the PropertyListParser with a FileInfo, a Stream or a byte array. The Parse method of the PropertyListParser will parse the input and give you a NSObject as result. Generally this is a NSDictionary but it can also be a NSArray.

Note: Property lists created by NSKeyedArchiver are not yet supported.

You can then navigate the contents of the property lists using the various classes extending NSObject. These are modeled in such a way as to closely resemble the respective Cocoa classes.

You can also directly convert the contained NSObject objects into native .NET Objects with the NSOBject.ToObject() method. Using this method you can avoid working with NSObject instances altogether.

Writing

You can create your own property list using the various constructors of the different NSObject classes. Or you can wrap existing native .NET structures with the method NSObject.Wrap(Object o). Just make sure that the root object of the property list is either a NSDictionary (can be created from objects of the type Dictionary<string, Object>) or a NSArray (can be created from object arrays).

For building a XML property list you can then call the ToXml method on the root object of your property list. It will give you an UTF-8 string containing the property list in XML format.

If you want to have the property list in binary format use the BinaryPropertyListWriter class. It can write the binary property list directly to a file or to a Stream.

When you directly want to save your property list to a file, you can also use the SaveAsXml or SaveAsBinary methods of the PropertyListParser class.

Converting

For converting a file into another format there exist convenience methods in the PropertyListParser class: ConvertToXml, ConvertToBinary, ConvertToASCII and ConvertToGnuStepASCII.

Code snippets

Reading

try
{
	FileInfo file = new FileInfo("Info.plist");
	NSDictionary rootDict = (NSDictionary)PropertyListParser.Parse(file);
	string name = rootDict.ObjectForKey("Name").ToString();
	NSObject[] parameters = ((NSArray)rootDict.ObjectForKey("Parameters")).GetArray();
	foreach(NSObject param in parameters)
	{
		if(param.GetType().Equals(typeof(NSNumber)))
		{
			NSNumber num = (NSNumber)param;
			switch(num.GetNSNumberType())
			{
				case NSNumber.BOOLEAN:
				{
					boolean bool = num.ToBool();
					// ...
					break;
				}
				case NSNumber.INTEGER:
				{
					long l = num.ToLong();
					// or int i = num.ToInt();
					// ...
					break;
				}
				case NSNumber.REAL:
				{
					double d = num.ToDouble();
					// ...
					break;
				}
			}
		}
		// else...
	}
}
catch(Exception ex)
{
	Console.WriteLine(ex.StackTrace);
}

Writing

// Creating the root object
NSDictionary root = new NSDictionary();

// Creation of an array of length 2
NSArray people = new NSArray(2);

// Creation of the first object to be stored in the array
NSDictionary person1 = new NSDictionary();
// The NSDictionary will automatically wrap strings, numbers and dates in the respective NSObject subclasses
person1.Add("Name", "Peter"); // This will become a NSString
// Use the DateTime class
person1.Add("RegistrationDate", new DateTime(2011, 1, 13, 9, 28, 0)); // This will become a NSDate
person1.Add("Age", 23); // This will become a NSNumber
person1.Add("Photo", new NSData(new FileInfo("peter.jpg")));

// Creation of the second object to be stored in the array
NSDictionary person2 = new NSDictionary();
person2.Add("Name", "Lisa");
person2.Add("Age", 42);
person2.Add("RegistrationDate", new NSDate("2010-09-23T12:32:42Z"));
person2.Add("Photo", new NSData(new FileInfo("lisa.jpg")));

// Put the objects into the array
people.SetValue(0, person1);
people.SetValue(1, person2);

// Put the array into the property list
root.Add("People", people);

// Save the property list
PropertyListParser.SaveAsXml(root, new FileInfo("people.plist"));
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 is compatible.  netcoreapp1.1 was computed.  netcoreapp2.0 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 is compatible.  netstandard1.5 was computed.  netstandard1.6 is compatible.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on plist-cil:

Package Downloads
JetBrains.Rider.Rider.Backend The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

JetBrains Rider Rider Backend Package Version 231.0.20240313.120032

Carbon.Feature.Network

Provides common networking features and functions.

Wky.Web.Core

内部公共代码

NSKeyedUnarchiver

Read NSKeyedArchiver generated plists.

AppleDev

Useful API's for Apple development related tasks

GitHub repositories (6)

Showing the top 5 popular GitHub repositories that depend on plist-cil:

Repository Stars
master131/iFakeLocation
Simulate locations on iOS devices on Windows, Mac and Ubuntu.
Redth/dotnet-maui-check
.NET MAUI Check tool
aaru-dps/Aaru
Aaru Data Preservation Suite
fuse-open/fuse-studio
Fuse Studio is a visual desktop tool suite for working with the Fuse framework
deanward81/AirDropAnywhere
An implementation of AirDrop that allows any web-enabled device to send/receive files to/from an AirDrop-compatible device
Version Downloads Last updated
2.2.0 830,936 4/30/2021
2.1.0 42,387 3/30/2020
2.0.0 9,215 9/20/2019
1.60.0 1,259,260 4/12/2019
1.50.0 60,499 7/9/2018
1.16.0 16,450 5/20/2017
1.15.0 1,922 2/22/2017
1.14.0 7,532 2/25/2015

Added support for .NETStandard2.0 and .NET Core 2.0.
     Added ParseString overloads.
     Fix roundtrip/serialization of real with > 5 digits.
     Correctly roundtrip long binary values.
     Fix XML serialization of binary values.
     Add support for Span<byte>.
     Fix serialization of UIDs.
     Fix roundtripping binary data
     Several performance improvements.
     Reduced allocations.
     Updated list of serialization primitives.