iOS App Rejection due to 2.23 - iOS Data Storage Guidelines

て烟熏妆下的殇ゞ 提交于 2019-12-02 17:36:37
Glauco Neves

I just got the same rejection message yesterday.

I use the following code in application:didFinishLaunchingWithOptions: to see what my application has inside the documents folder and what is the permission of each item about iCloud backup:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSArray *documents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:basePath error:nil];
NSURL *URL;
NSString *completeFilePath;
for (NSString *file in documents) {
    completeFilePath = [NSString stringWithFormat:@"%@/%@", basePath, file];
    URL = [NSURL fileURLWithPath:completeFilePath];
    NSLog(@"File %@  is excluded from backup %@", file, [URL resourceValuesForKeys:[NSArray arrayWithObject:NSURLIsExcludedFromBackupKey] error:nil]);
}

I had some files inside that folder that were synchronising with iCloud. So instead of saving those files in another place I set the resource value for the NSURLIsExcludedFromBackupKey key set to YES to exclude those files from being backed up by iCloud, like this:

NSURL *URL = [NSURL fileURLWithPath:photoPath];
[URL setResourceValue:@(YES) forKey:NSURLIsExcludedFromBackupKey error:nil];

I'm sending my app again today to see if works.

Hope this help.

Recently, we were rejected by Apple Review Team with the same issue,

On launch and content download, your app stores 9.65MB on the user's iCloud, which does not comply with the iOS Data Storage Guidelines.

They suggest to follow the same Next Steps as mentioned in the question above.

In our case, we are already setting this NSURLIsExcludedFromBackupKey in the code when downloading contents. We informed the review team that we are already doing this, so they redirected us to Apple Developer Technical Support (DTS) to better address the issue.

DTS replied that it is our AppIcon files that are causing the issue.

The AppIcons are being backed up in iCloud as Apple requires to display an icon on the device while the app is being downloaded. It turns out that our app's AppIcons files are so big that caused the rejection because it is backing up a lot of data to iCloud. This was not communicated clearly to us by the App Review team as some of them are not aware of this new tool changes that track the AppIcons.

Now that we know the reason, we optimized our icons using ImageOptim and minimized the size to 75KB.

We submitted our app and hopefully it will be approved in 1 to 2 days. :)

I hope this helps someone who has the same issue. :)

Ran into this same issue recently and just translated Glauco's answer to Swift (though it could probably be written more Swiftly)

let directories = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true)
    if let documentDirectory = directories.first {
        do {
            let documents = try NSFileManager.defaultManager().contentsOfDirectoryAtPath(documentDirectory)
            for files in documents {
                let urlForm = NSURL.fileURLWithPath(documentDirectory + "/" + files)
                do {
                    try print("\(files): \(urlForm.resourceValuesForKeys([NSURLIsExcludedFromBackupKey]))")
                } catch {
                    print("can't find key")
                }
            }
        } catch {
            print("can't retrieve contents")
        }
    }

Code to setResourceValue

let urlToExclude = NSURL.fileURLWithPath(quoteSavePath!)
    do {
        try urlToExclude.setResourceValue(NSNumber(bool: true), forKey: NSURLIsExcludedFromBackupKey)
    } catch { print("failed to set resource value") }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!