Class 'ARCollaborationData' disallows secure coding

129 views Asked by At

I have an app that offers collaboration in AR and I was following the docs on how to send ARSession.CollaborationData using MultipeerConnectivity.

https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration/3152987-iscollaborationenabled

It appears that, with iOS 14, this is no longer possible. I receive the following error when I try to unarchive:

Class 'ARCollaborationData' disallows secure coding. It must return YES from supportsSecureCoding.

I'm more or less using the exact some code as given in the documentation and it worked flawlessly with iOS 13. Now, with iOS 14, I am not sure how to fix this issue. I've tried sending it with requiringSecureCoding: false as well as trying to create an NSKeyedUnarchiver which has requiresSecureCoding set to false as well. As far as I'm aware, I'm not able to change the implementation of NSSecureCoding for ARSession.CollaborationData (which is supposedly present anyway).

This is the code that sends the data:

guard let encodedData = try? NSKeyedArchiver.archivedData(
    withRootObject: data,
    requiringSecureCoding: true
)
else { fatalError("Unexpectedly failed to encode collaboration data.") }
// Use reliable mode if the data is critical, and unreliable mode if the data is optional.
let dataIsCritical = data.priority == .critical
try session.send(
    encodedData,
    toPeers: session.connectedPeers,
    with: dataIsCritical ? .reliable : .unreliable
)

And I decode everything by calling this function:

NSKeyedUnarchiver.unarchivedObject(ofClass: ARSession.CollaborationData.self, from: data)

Has anyone else had this issue before? Could it be that this is a bug and I just have to report it and wait? Either way, thanks in advance for any hints or tips :) They are greatly appreciated!

Best regards, Bjoern

0

There are 0 answers