应用程序因文档目录中的数据而被拒绝

问题描述:

在我的应用程序启动时,它会将一个库从我的资源文件夹复制到 iOS 设备上的文档目录.这是第一次启动时的一次性过程,再也没有接触过.Apple 今天拒绝了我的应用程序,原因如下:

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:

我们发现您的应用没有遵循 iOS 数据存储不符合 App Store Review 的指南指南.

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

iOS 数据存储指南表明,只有用户使用您的应用程序创建,例如文档、新文件、编辑等,应该由 iCloud 备份.

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.

您的应用程序使用的临时文件应仅存储在/tmp目录;请记住删除存储在此位置的文件当用户退出应用程序时.

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.

可以重新创建但必须保留以确保正常运行的数据您的应用程序 - 或者因为客户希望它可以离线使用使用 - 应标有不备份"属性.对于 NSURL对象,添加 NSURLIsExcludedFromBackupKey 属性以防止相应的文件被备份.对于 CFURLRef 对象,使用对应的 kCFURLIsExcludedFromBackupKey 属性.

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];
  });
  }
 }
}

谢谢

Apple 发布了 文件系统编程指南,您应该阅读并遵循.听起来您的库是用户不应该看到的应用程序的内部细节.因此,它不应位于 Documents 目录中.考虑使用 Library 或 Library/Caches 目录.

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.