0

I've saved my RoomPlan.CapturedRoom in CoreData as a Data object. When I open it again on a device WITH a LiDAR Scanner, it works totally fine. However, when I try to open it on the simulator for example, I get an error saying "RoomPlan.CapturedRoom.Error.deviceNotSupported".

The code I use to convert the Data back to a CapturedRoom is this:

let decoder = JSONDecoder()
            
do {
    self.capturedRoom = try decoder.decode(CapturedRoom.self, from: capturedRoomData)
} catch {
    let nserror = error as NSError
    fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}

The fatalError is thrown here giving me the error above.

denniswave
  • 127
  • 6
  • "deviceNotSupported" : I guess the simulator isn't supported. Avoid a `fatalErrror` if you don't want a crash. It's confirmed with https://developer.apple.com/forums/thread/666947 – Larme Jan 17 '23 at 11:01
  • I guess that's the case. A real device without a LiDAR Scanner is not supported either. This seems a bit dumb since I only want to view the data and not make a scan. Is there any workaround for this? – denniswave Jan 18 '23 at 10:00
  • 1
    You can write your own class and map it to Apples CapturedRoom, and implement Codable. Another solution is to export the CapturedRoom to JSON. – Darkwonder Mar 30 '23 at 11:50
  • Thanks! I actually ended up doing this :) – denniswave Apr 21 '23 at 13:40

1 Answers1

0

The solution posted by @Darkwonder is the right approach to this: "You can write your own class and map it to Apples CapturedRoom, and implement Codable. Another solution is to export the CapturedRoom to JSON."

denniswave
  • 127
  • 6