'Deserializing ARWorldMap in Unity that was serialized with NSKeyedArchiver in native iOS

I have developed an iOS/ARKit app that functions as a content editor for my AR game. It has a fair amount of interface that I don't want to port over to Unity, but I want to be able to save my ARWorldMaps from the iOS editor app and load them into my Unity AR game.

I'm using NSKeyedArchiver to serialize my ARWorldMap like this:

func serializeMap(_ worldMap: ARWorldMap) -> Data {
    return try! NSKeyedArchiver.archivedData(withRootObject: worldMap, requiringSecureCoding: true)
}

Any ideas how I could use those bytes returned from serializeMap to load the map in Unity using ARWorldMap.TryDeserialize?



Solution 1:[1]

It should look rather like

func deserializeMap(_ data: Data) -> ARWorldMap? {
    return try? NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: data)
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asperi