UIImagePicker sheet disappears when search field takes focus in SwiftUI

import SwiftUI

// MARK: - ImagePickerApp
@main struct ImagePickerApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

// MARK: - ContentView
struct ContentView: View {
  @State var showPicker = false

  var body: some View {
    Button { showPicker = true } label: {
      Image(systemName: "camera.circle.fill")
        .resizable()
    }
    .frame(width: 100, height: 100, alignment: .center)
    .sheet(isPresented: $showPicker) {
      ImagePicker()
    }
  }
}

// MARK: - ImagePicker
struct ImagePicker: UIViewControllerRepresentable {
  class Coordinator: NSObject {}

  func makeCoordinator() -> Coordinator { Coordinator() }

  func makeUIViewController(context _: Context) -> UIImagePickerController { UIImagePickerController() }

  func updateUIViewController(_: UIImagePickerController, context _: Context) {}
}

This is a minimal repro case for a SwiftUI app that exhibits what I think is a system bug.

Is there any solution?

Also experiencing this issue and have spent a few hours trying to find a solution.

Any help would be appreciated.

The exception is:

viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}

It occurs when tapping the search field within the Image Picker view.

This SO question appears to report the same issue: https://stackoverflow.com/questions/69306179/phpickerviewcontroller-tapping-on-search-gets-error-unable-to-load-photos

UIImagePicker sheet disappears when search field takes focus in SwiftUI
 
 
Q