Problems with draggable and dropDestination using DataRepresentation in Transferable

I can't get my drag and drop with DataRepresentation to work with Transferable. I'm trying to drag and drop instances of DataSettings which is an NSManagedObject that conforms to NSSecureCoding.

Here's my UTType:

extension UTType {
  static var encoderSettings = UTType(exportedAs: "com.simulator.EncoderSettings")
}

Here's my conformance to Transferable:

extension DataSettings: Transferable {
  var data: Data? {
    try? NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: true)
  }

  public static var transferRepresentation: some TransferRepresentation {
    /*DataRepresentation(contentType: .commaSeparatedText) { setting in
      let data = setting.data
      print("DataRepresentation: \(data)")
      return data!
    } importing: { data in
      print("data: \(data)")
      return DataSettings()
    }*/

    DataRepresentation(contentType: .encoderSettings) { setting in
      let data = setting.data
      print("DataRepresentation: \(data)")
      return data!
    } importing: { data in
      print("data: \(data)")
      return DataSettings()
    }

//    ProxyRepresentation(exporting: \.title)
  }
}

Here's a view where I'm testing my drop destination:

struct DropTest: View {
  @State var isDropTargeted = false
  var body: some View {
    Color.pink
      .frame(width: 200, height: 200)
      .dropDestination(for: EncoderSettings.self) { setting, location in
        print("\(setting)")
        return true
      } isTargeted: {
        isDropTargeted = $0
        print("Got it!!!")
      }
  }
}

Here's my Info plist:

The ProxyRepresentation (String) works but I need the actual Data. The dragging starts (i.e.: I can drag the view that has the .draggable with DataSettings) but I can't drop it on my DropTest view. I can drop it on a view or app that accepts the ProxyRepresentation.

What am I missing?

Replies

Did you ever find a solution for this? I'm trying to do a similar thing, drag and drop instances of an NSManagedObject. Doing all the things you did yields the same result for me - I can drag but can't drop.