PHPickerViewController getting error on selecting first image from simulator

I am getting the below error on selecting the first image from the simulator photo library.

for itemProvider in parent.itemProviders {
    if itemProvider.canLoadObject(ofClass: UIImage.self) {
        itemProvider.loadObject(ofClass: UIImage.self) { (image, error) in
            if let image = image as? UIImage {
                self.parent.images.append(image)
            } else {
                print("Could not load image", error?.localizedDescription ?? "")
            }
        }
    }
}

When I select the first image I am getting the below error
Cannot load representation of type public.jpeg

Also, how can I persist the selection when I open the photo library again?

On your first question, I have the same problem. Seems an issue with the simulator only, on my iPhone all is well.

On your second: do you want to keep selected items selected for next time, or do you mean to save the selected photos? Not sure if the first is possible. If the second, there is a nice tutorial on Hacking With Swift: 100 Days of SwiftUI.