Can't load/decode PKDrawing using any of the new inks (version 2, iOS 17)

I am using Xcode 15 beta 5 with iOS 17 beta 4 SDK. By building with the iOS 17 SDK my app got all the new inks which work great. Saving/encoding the PKDrawing to Data also works fine. However if I want to load the same PKDrawing again, on the same simulator or device (i.e., same iOS version) it fails with "Apple Drawing Format is from a future version that is too new.".

From my understanding, reading https://developer.apple.com/documentation/pencilkit/supporting_backward_compatibility_for_ink_types?changes=_2 this is the expected behaviour when trying to load such a PKDrawing on an older iOS version which doesn't support the new ink types.

Here is a short example, which prints the error:

        var drawing = PKDrawing()
        let strokePoints = [
            PKStrokePoint(location: CGPoint(x: 0, y: 0), timeOffset: 0, size: CGSize(width: 3.0, height: 3.0), opacity: 2, force: 1, azimuth: 1, altitude: 1)
        ]
        let strokePath = PKStrokePath(controlPoints: strokePoints, creationDate: Date())
        
        drawing.strokes.append(PKStroke(ink: .init(.watercolor), path: strokePath))

        do {
            let data = drawing.dataRepresentation()
            let drawing2 = try PKDrawing(data: data)
            print("success")
        } catch {
            print(error)
        }
    }

Saving & loading a PKDrawing which does not use any of the new ink types works fine.

same, how to fix the problem?

Can't load/decode PKDrawing using any of the new inks (version 2, iOS 17)
 
 
Q