2
votes

on the launch of my app, it copies a library from my resources folder to the documents directory on the iOS device. This is a one time process on the first launch and never touched again. Apple today rejected my app with the following:

We found that your app does not follow the iOS Data Storage Guidelines, which is not in compliance with the App Store Review Guidelines.

The iOS Data Storage Guidelines indicate that only content that the user creates using your app, e.g., documents, new files, edits, etc., should be backed up by iCloud.

Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.

Data that can be recreated but must persist for proper functioning of your app - or because customers 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 kCFURLIsExcludedFromBackupKey attribute.


I am not sure how to set up the do not backup attribute or whether it is what I need. Can anyone tell me how this is done based on my code?

-(void) progress
{
 NSFileManager *fileManager = [NSFileManager defaultManager];
 NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = ([documentPaths count] > 0) ? [documentPaths objectAtIndex:0] : nil;
NSString *dataPath = [documentPath stringByAppendingPathComponent:pathWeSet];

if (![fileManager fileExistsAtPath:dataPath]) {
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *dataPath = [bundlePath stringByAppendingPathComponent:pathWeSet];
timer = [NSTimer timerWithTimeInterval:0.4 target:self selector:@selector(updateProgressView) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[timer fire];
if (dataPath) {
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    [fileManager copyItemAtPath:dataPath toPath:dataPath error:nil];
  });
  }
 }
}

Thanks

1
Why is the data copied to the Documents folder? What is the data? Is the data updated by the user or is it read-only? - rmaddy
@rmaddy It is a library for the sake of simplicity that I need to be transferred to the documents directory for reading every time the app is used. It is transferred once and then read every time the app is used. Thanks! - Teddy13
If it is read-only then there is no reason to copy it anywhere. Just read it from the resource bundle every time. - rmaddy
@rmaddy It is very slow and cannot work that way. I understand this is a vague answer but I tested this thoroughly and found supporting documentation. So without going to deep, it "has" to be copied over. Thanks - Teddy13

1 Answers

3
votes

Apple publishes a File System Programming Guide which you should read and follow. It sounds like your library is an internal detail of your app that the user should not see. Therefore, it should not be in the Documents directory. Consider using the Library or Library/Caches directory.