"Missing required primary zone" error in Photos framework

Hello,


I have the following error "Missing required primary zone" when trying to download a photo from iCloud.


All the permissions are correctly set, and generally I get this error on the first try, but if I try another time, it succeeds without error.


Could you help me with that? What is the root cause of this error message and what is the "primary zone"


Code:


    PHImageRequestOptions *options = [PHImageRequestOptions new];
    options.version = PHImageRequestOptionsVersionCurrent;
    options.synchronous = YES;
    options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
    options.resizeMode = PHImageRequestOptionsResizeModeNone;
    options.networkAccessAllowed = YES;
    options.progressHandler = ^(double progress, NSError *__nullable error, BOOL *stop, NSDictionary *__nullable info) {
        assetProgressBlock(progress);
        if (error) {
            DDLogError(@"Error while downloading asset from iCloud: %@", error);
            *stop = YES;
        }
    };
    [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
        if (!imageData) {
            DDLogError(@"Error while downloading image: %@", info[PHImageErrorKey]);
            return;
        }
        UIImage *image = [[UIImage alloc] initWithData:imageData];
     
        [self processImage:image];
    }];



Error log:


[Generic] Failed to load image data for asset <PHAsset: 0x109aacfd0> 93A9C44B-8B63-4B22-AAD0-7DC042843C4D/L0/001 mediaType=1/8, sourceType=1, (3024x4032), creationDate=2018-03-03 11:46:56 +0000, location=1, hidden=0, favorite=0  with format 9999
Error while downloading asset from iCloud: Error Domain=CloudPhotoLibraryErrorDomain Code=80 "Missing required primary zone" UserInfo={NSLocalizedDescription=Missing required primary zone}

Replies

I'm hitting the same error - it might be a regression as the my code wsa tested and working on iOS 11.0

I'm also getting the same error a lot in iOS 11. It has to be something in iOS 11 that is causing this.

This appears fixed on iOS 12 to us despite others reporting the contrary: https://stackoverflow.com/a/49868055