I've succesfully created a number of UIViewControllerRepresentable using various UIViewController, with one exception: CNContactPickerViewController. Everything I've tried has given me a blank white screen. Is this UIViewController special in some way that makes it currently incompatible?
import SwiftUI
import ContactsUI
// Minimal version
struct LookupContactViewController : UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> CNContactPickerViewController {
let contactPickerVC = CNContactPickerViewController()
contactPickerVC.delegate = context.coordinator
return contactPickerVC
}
func makeCoordinator() -> Coordinator {
return Coordinator()
}
func updateUIViewController(_ uiViewController: CNContactPickerViewController, context: Context) {
}
class Coordinator: NSObject {
}
}
extension LookupContactViewController.Coordinator : CNContactPickerDelegate {
func contactPickerDidCancel(_ picker: CNContactPickerViewController) {
print("Cancelled!")
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
print("Chose: \(contact.givenName)")
}
}
#if DEBUG
struct LookupContact_Previews : PreviewProvider {
static var previews: some View {
LookupContactViewController()
}
}
#endif