How to get images that are in iCloud with PHPickerViewController?

I have been searching high and low for anyone that has encountered the same issue,

My problem is when an image is not actually on the device but rather in iCloud, my app fails to retrieve the image. How would i go about remedying this?

My code for PHPicker implementation is as follows, any help would be greatly appreciated.

Code Block
extension PageViewController: PHPickerViewControllerDelegate {
   
  func presentPicker() {
    ArtModel.holdingBay.removeAll()
    var configuration = PHPickerConfiguration()
    configuration.filter = .images
    configuration.selectionLimit = 5
    let picker = PHPickerViewController(configuration: configuration)
    picker.delegate = self
    present(picker, animated: true)
  }
   
  func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
    if results.count > 0 {
      for result in results {
        result.itemProvider.loadObject(ofClass: UIImage.self, completionHandler: { (object, error) in
          if let image = object as? UIImage {
            DispatchQueue.main.async {
              ArtModel.holdingBay.append(image)
            }
          }
        })
      }
    }
    picker.dismiss(animated: true, completion: self.holdingBayCheck)
  }
   
  func holdingBayCheck() {
    if ArtModel.holdingBay.count > 0 {
      performSegue(withIdentifier: K.goToCrop, sender: self)
    }
  }
   
}




Answered by Engineer in 676087022
You don’t need to do anything special to support iCloud Photos. Please make sure you have a good internet connection. You should also prompt your users if assets can’t be retrieved (e.g. not connected to the internet).
Accepted Answer
You don’t need to do anything special to support iCloud Photos. Please make sure you have a good internet connection. You should also prompt your users if assets can’t be retrieved (e.g. not connected to the internet).

I have a problem with PHPicker, because it doesn't download photos at first time if they are in iCloud and not on the device. However if i try second time it is downloaded and works well.

How to get images that are in iCloud with PHPickerViewController?
 
 
Q