NSPropertyListXMLFormat_v1_0 option for dataWithPropertyList complaining of size limit in iOS 14.4

I use dataWithPropertyList with NSPropertyListXMLFormat_v1_0 to convert local data in an NSDictionary to NSData to be sent to Server side as a .plist (readable as xml for troubleshooting).

Ever since iOS 14.4, the process fails at dataWithPropertyList, with errors as: "Property list invalid for format: 100 (Too many nested arrays or dictionaries)" and in iOS 14.7 a little more verbose: "Property list invalid for format: 100 (Too many nested arrays or dictionaries please use kCFPropertyListBinaryFormat_v1_0 instead which supports references)"

The error only takes place when running in iOS 14.4 and above (regardless of actual iOS Device or Simulator). Issue doesn't take place when using same source code but compiling for any iOS 14.3 and lower.

Using the Binary option as the latest verbose error suggests does work. Ironically the resulted NSData is larger than original xml based one, and I lose the ability to read xml server side.

Anyone else experienced these issues? Apparently Apple is aware of the issue given they updated the verbose error message in iOS 14.7. Do they intend to fix it so it works as it does in iOS 14.3 and lower? Or are there other suggestions on working around the issue so I can still have the xmls? Alternative methods?

Regards,

Do they intend to fix it so it works as it does in iOS 14.3 and lower?

No. This was a deliberate change to improve security and reliability (r. 61207578). The specific limit is arbitrary, but it reflects that fact that property lists were always intended to be a convenient way to wrangle a relatively simple data structure, rather than the ultimate API for serialisation.

For your specific case I’d recommend one of the following:

  • Use a binary property list. There are third-party libraries you can use to parse this on the server.

  • Restructure your data to reduce recursion. If, for example, you look at the on-disk representation of an Xcode project, you’ll see that it represents a very complex structure without excessive recursion.

  • Use a ‘real’ serialisation library. If you want to stick with your existing XML representation, there are plenty of XML libraries that support arbitrary nesting (both system libraries and from third parties). Or you could change to something more efficient (here you’d want to look in the third-party space, looking at either JSON-focused libraries or libraries that target completely different technologies, like protobuf).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

NSPropertyListXMLFormat_v1_0 option for dataWithPropertyList complaining of size limit in iOS 14.4
 
 
Q