Photos sample app can't access full-resolution photos on iOS

I'm running this SwiftUI sample app for photos without any modifications except for adding my developer profile, which is necessary to build it. When I tap on the thumbnail to see the photo library (after granting access to my photo library), I see that some of the thumbnails are stuck in a loading state, and when I tap on thumbnails, I only see a low-resolution image (the thumbnail), not the full-resolution image that should load.

In the console I can see this error that occurs when tapping on a thumbnail to see the full-resolution image:

CachedImageManager requestImage error: The operation couldn’t be completed. (PHPhotosErrorDomain error 3164.)

When I make a few modifications necessary to run the app as a native macOS app, all the thumbnails load immediately, and clicking on them reveals the full-resolution images.

Replies

That error is "network access required." It means that the asset you are requesting needs to be downloaded to be viewed. The SwiftUI sample app does not appear to be allowing network access for image manager requests (in CachedImageManager.swift), via the request option

When I make a few modifications necessary to run the app as a native macOS app, all the thumbnails load immediately, and clicking on them reveals the full-resolution images.

Is it possible that you opened the system Photos app or that your photo library had time to sync up in the background while you were doing this?

Thanks! That solved the issue. This part should really be modified in the sample app:

  private lazy var requestOptions: PHImageRequestOptions = {
    let options = PHImageRequestOptions()
    options.deliveryMode = .opportunistic
    options.isNetworkAccessAllowed = true // <- Add this
    return options
  }()