Drag and Drop Contacts not working in Ventura

This code was working fine in Monterey but since upgrading to Ventura it no longer works:

let contactsUTTypes = [UTType.vCard, UTType.contact]

func performDrop(info: DropInfo) -> Bool
{
    print (info)

    let items = info.itemProviders(for: contactsUTTypes)
    print (items)

    for item in items
    {
        item.loadDataRepresentation(forTypeIdentifier: UTType.vCard.identifier, completionHandler: { (data, error) in

            if let data = data,
               let contact = try? CNContactVCardSerialization.contacts(with: data).first
            {
                print("Contact: \(contact.givenName)")
            }
        })
    }
    return true
}

let items = info.itemProviders(for: uttypes)

always returns zero items

Has this been broken in Ventura or do I need to do this differently now?

Hi! What version of Ventura do you have?

Can you please check if this snippet works for you?

import SwiftUI
import UniformTypeIdentifiers

let contactsUTTypes = [UTType.vCard, UTType.contact]

struct DropContactVCard: View {
    let delegate = VCardDelegate()
    var body: some View {
        HStack {
            RoundedRectangle(cornerRadius: 4.0)
                .foregroundStyle(Color.pink)
                .onDrop(of: contactsUTTypes, delegate: delegate)
        }
    }
}

final class VCardDelegate: DropDelegate {
    func validateDrop(info: DropInfo) -> Bool {
        print("info: \(info)")
        return true
    }

    func performDrop(info: DropInfo) -> Bool {
        let items = info.itemProviders(for: contactsUTTypes)
        print ("items \(items)")
        if let first = items.first {
            print("types: \(first.registeredContentTypes)")
        }
        for item in items {
            item.loadDataRepresentation(forTypeIdentifier: UTType.vCard.identifier, completionHandler: { (data, error) in
                if let data = data {
                    print("Received data: \(data)")
                }
                if let error {
                    print("Error: \(error)")
                }
            })
        }
        return true
    }
}
Drag and Drop Contacts not working in Ventura
 
 
Q