Rejected iPhone application by Apple developers du

2019-02-19 18:45发布

Application rejected due to "do not back up" reason

I tried one thing to remove this issue. I got one small code from Apple technical support and used this code in my project according to iOS guideLines. First, I added a header file in my appdelegate.m part

#import<sys/xattr.h>    

Then paste the below function.

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];

    const char* attrName = "com.apple.MobileBackup";
    u_int8_t attrValue = 1;

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
    return result == 0;
}

And call the above function to my appdelegate when it finishes launching.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;

    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:@"<Application_Home>/Library/Caches"]];
    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:@"<Application_Home>/tmp"]];
    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:@"<Application_Home>/Library/Private Documents"]];
}

Now I just want to know if this OK or not. Can I reupload my application on iTunes Connect or not?

2条回答
仙女界的扛把子
2楼-- · 2019-02-19 19:25

You should set the attribute at the point where you create the folder. If you try setting the attributes during didFinishLaunching and the folders don't exist yet (ie, on first launch) then once they are created they won't have the attribute set. It'll get set correctly the next time your app is launched, but you'll still end up creating backups between the first and second runs.

Also, the Library/Caches folder is automatically excluded from backups I believe.

查看更多
3楼-- · 2019-02-19 19:32

I have found a solution regarding this issue. We should not keep any large memory database. For removing this issue, I removed all the images which were placed in db.sqlite (db.sqlite is my database name). Now I have made a new db.sqlite. In this I have kept only images names, and images are kept in my project folder.

If you have a heavy database in your applications then you will have to follow iCloud. Now Apple accepts my application, and it got approved. :-)

Also read this - data storage guidelines

  • Critical data that cannot be recreated, such as documents or user-specific data that would be lost if the device were damaged, goes into the <Application_Home>/Documents directory and will be backed up by iCloud unless otherwise specified.

  • Cached data that can be recreated, such as a local database or downloaded images, goes into the <Application_Home>/Library/Caches directory and will not be backed up by iCloud. This data may get purged at some point if iOS runs low on disk space.

  • Temporary data that is transient and not used between application launches, such as a temporary file cache, goes into the <Application_Home>/tmp directory and will not be backed up by iCloud. You should always remember to delete files stored here yourself.

  • Offline data that needs to be persistent and available when the device is offline (such as Airplane Mode), goes into the <Application_Home>/Library/Private Documents directory and will not be backed up by iCloud, but also it will not be purged by iOS in a low disk space situation. For more information about Private Documents in iOS.

查看更多
登录 后发表回答