WTF. How is UUID not one of the types you can store in @SceneStorage? And worse, how come the limited types usable aren't documented*? #Swift #SwiftUI

*I've searched the pages for SceneStorage, AppStorage, and “Restoring your app's state with SwiftUI" and haven't found mention of data type restrictions.

I scrutinized the “Restoring your app's state with SwiftUI" page and found this one sentence buried innocuously in a dense paragraph: “The value is required to be of a plist type, so the system can save and restore it correctly.”

https://developer.apple.com/documentation/swiftui/restoring-your-app-s-state-with-swiftui

Nowhere does it list what “plist type” contains, nor does it link to a definition. After manually searching for plist types I found the “Information Property List" page on Apple's documentation site, which also does not provide any useful information about supported data types.

https://developer.apple.com/documentation/bundleresources/information-property-list

#Swift #SwiftUI

Restoring your app’s state with SwiftUI | Apple Developer Documentation

Provide app continuity for users by preserving their current activities.

Apple Developer Documentation

@gregatron5 this is old-school Cocoa stuff. There is an old document listing the types here: https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html

I can't imagine why a current/new Swift API would depend on plist types, rather than Codable conformance, though.

Property list

A collection of short articles on the core concepts, patterns, and mechanisms in Cocoa programming.

@mbessey @gregatron5 Binary PLISTs are more compact than JSON. That could be a factor? Potentially there is some CF era API they need here for some reason that requires PLIST?

@vanvoorden @mbessey Looks like someone was lazy. According to WIkipedia the binary plist format supports UUIDs but the XML version does not. I suppose SceneStorage inherited the worst of both worlds.

https://en.wikipedia.org/wiki/Property_list

Property list - Wikipedia

@gregatron5 @mbessey Right… if the infra wants binary PLIST for smaller size *plus* xml bridging after the binary is decoded that could be where the restrictions are coming from.
@mbessey @gregatron5 I think PLIST might also have easier bridging to XML. There could be some XML parsing logic happing inside that makes PLIST the better choice?