I was also getting nil values when using NSItemProvider method loadPreviewImage. I tested on device as well as simulator(iOS version 15.5 and 15.2). Has anyone seen this issue persisting in current versions of iOS
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
picker.dismiss(animated: true, completion: nil)
if let itemProvider = results.first?.itemProvider {
if(itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier)) {
itemProvider.loadPreviewImage { secureCoding, error in
print("I am getting (secureCoding) and (error)")
}
}
}
}
Output: I am getting nil and nil