Flag "do-not'backup" files in iOS Main Bundle

222 views Asked by At

I uploaded an app to Appstore but got rejected due to files being backed up to iCloud, when only user generated content should be backed up.

The thing is that I have a json in MainBundle that I use only the first time to create and update CoreData. Once I update CoreData, the json is no longer needed. I tried a solution to delete this json file but I can't since it's not permitted by Apple to delete or edit content from the Main Bundle. I, then, leave the json unused and in the Main Bundle, but the app was rejected due to this file being backed up to iCloud.

I tried this solution below, that Apple gave me to solve this problem:

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

    NSError *error = nil;
    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
    return success;
}

I still can't solve the problem, because every time I try to use this code, I get this error:

NSUnderlyingError=0x15f87bb0 "The operation couldn’t be completed. Operation not permitted"

My understanding is that I can't flag the json as "do-not-backup" because I can't delete or edit any files that are in MainBundle. I tried arguing with Apple that this happens but got the same response from them.

Any ideas on how to solve this problem?

0

There are 0 answers