Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS App Rejection due to 2.23 - iOS Data Storage Guidelines

Here's message from Apple about rejection :

2.23 - Apps must follow the iOS Data Storage Guidelines or they will be rejected 2.23 Details

On launch and content download, your app stores 6.5 MB, which does not comply with the iOS Data Storage Guidelines.

Next Steps

Please verify that only the content that the user creates using your app, e.g., documents, new files, edits, etc. is backed up by iCloud as required by the iOS Data Storage Guidelines. Also, check that any temporary files used by your app are only stored in the /tmp directory; please remember to remove or delete the files stored in this location when it is determined they are no longer needed.

Data that can be recreated but must persist for proper functioning of your app - or because users expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCRUFLIsExcludedFromBackupKey attribute.

I checked out the data files of my application both for device and simulator. I found that if app has used for a while, it's total app data could store 5-6 MB, on launch. But I uninstalled and re-installed app and checked again, I see ~3MB data store on launch of app.

I'm not storing any Core Data databases or any other database files. But I've realized that Google Analytics and Google Tag Manager stores some sqlite data on this path : "AppData/Library". I mean it does NOT store on this path : "AppData/Library/Caches". Does it make any difference for iOS Data Storage Guidelines?

By the way, iCloud is disabled for application.

Also I'm using SDWebImage for downloading images and it stores almost 3 MB images on the launch and it stores image data on this path : "AppData/Library/Caches"

Do you have any idea that what should I do to handle this issue?

like image 310
ersentekin Avatar asked Mar 01 '15 16:03

ersentekin


3 Answers

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.

like image 101
Glauco Neves Avatar answered Nov 09 '22 04:11

Glauco Neves


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. :)

like image 7
KarenAnne Avatar answered Nov 09 '22 05:11

KarenAnne


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") }
like image 5
Antonydatiga Avatar answered Nov 09 '22 04:11

Antonydatiga