iOS Data Storage issue - Rejected even after NSURLIsExcludedFromBackupKey
Asked Answered
P

3

9

My app is rejected from app store multiple times for not following 'iOS Data Storage Guidelines'. I have marked all document directories with "do not back up" attribute as suggested by apple review team, as shown:

- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString
{
    NSURL* URL= [NSURL URLWithString:filePathString];

    NSError *error = nil;
    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];

    return success;
}

I have called the above addSkipBackupAttributeToItemAtPath method for all NSDocumentDirectory as shown :

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    [self addSkipBackupAttributeToItemAtPath:[paths objectAtIndex:0]];

and review team says it is still storing some data as backup to iCloud and it is being rejected by Apple review team, actually i don't want anything to back up. Is there anything i have missed to Skip Backup Attribute? or anything wrong in my code? please help. Thank you.

Prudery answered 26/2, 2016 at 6:34 Comment(5)
We just got the same rejection as you did, we did a full check on every directory to make sure they all created with the NSURLIsExcludedFromBackupKey, finger crossedGarget
@Bastet,got any solution?Prudery
Some of our apps have the rejection in regard to this issue, though we only found a few KB. We reply with screenshot base on our observation. One is approved. Others were rejected and the resubmission with this modification is in the reviewing process now.Garget
We response the rejection with a film of a newly device through installing our app and check the space in iCloud. It got approved the next day.Garget
Finally this was my issue: Data that can be downloaded again or regenerated should be stored in the <Application_Home>/Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.Prudery
C
3

Write this code in addSkipBackupAttributeToPath method. I had the same issue and was resolved by writing this code instead.

- (void)addSkipBackupAttributeToPath:(NSString*)path
{
   u_int8_t b = 1;
   setxattr([path fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
Cupellation answered 4/3, 2016 at 12:16 Comment(0)
M
2

Try using the NSCachesDirectory instead of the NSDocumentDirectory, to store the subfolders/files.

Malcom answered 9/3, 2016 at 3:3 Comment(1)
Yes, use the NSCachesDirectory. Also run in the simulator and see whether there is any data being saved in addition to what you expect to save. You might have forgotten to remove some code which you may have used earlier in your project.Bartholomeo
P
0

Even though i am using 'do not back up' attribute i was storing the downloadable contents in \Documents directory, so as per the priority \Documents contents will automatically backed up to icloud.

Apple doc says:

  1. Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and will be automatically backed up by iCloud.

  2. Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

  3. Data that is used only temporarily should be stored in the /tmp directory. Although these files are not backed up to iCloud, remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.

  4. Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically.

Prudery answered 3/6, 2017 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.