apps须遵循iOS数据存储指南

79 篇文章 0 订阅
46 篇文章 0 订阅

2.23 Apps must follow the iOS Data Storage Guidelines or they will be rejected

 苹果审核折腾人啊,这次是数据存储的事

 

2.23 Apps must follow the iOS Data Storage Guidelines or they will be rejected

2.23应用程序必须遵循iOS数据存储指南,否则他们将被拒绝

 

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

我们发现你的应用程序没有遵循iOS数据存储的指导方针, 这是每个应用程序商店要求审查指南。

 

In particular, we found that on launch and/or content download, your app stores 7.38MB. To check how much data your app is storing:

特别是,我们发现在启动或内容下载,你的应用程序商店7.38 mb。检查你的程序是多少数据存储:

 

- Install and launch your app

- Go to Settings > iCloud > Storage & Backup > Manage Storage

- If necessary, tap "Show all apps"

- Check your app's storage

——你的应用程序安装和启

——去设置> > >存储和备份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.

iOS数据存储指南表明,只有内容,使用你的应用程序的用户创建,例如文档、新文件,编辑等,应由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.

临时文件所使用的应用程序应该只被存储在/ tmp目录;请记住删除在这个位置的文件存储,当用户退出应用程序时。

 

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.

数据,可以重新创建但是必须持续正常运行你的应用程序——或因为客户期望它能离线使用,应该被标上不支持属性。对于NSURL对象,添加NSURLIsExcludedFromBackupKey属性来防止相应的文件从备份。 为CFURLRef对象,使用相应的kCFURLIsExcludedFromBackupKey属性。

 

For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.

有关更多信息,请见技术问答1719:我如何防止文件备份到iCloud和iTunes ?。

It is necessary to revise your app to meet the requirements of the iOS Data Storage Guidelines.

For discrete code-level questions, you may wish to consult with Apple Developer Technical Support. Please be sure to:

 

- include the complete details of your rejection issues

- prepare any symbolicated crash logs, screenshots, and steps to reproduce the issues for when the DTS engineer follows up.

有必要修改您的应用程序以满足需求的iOS数据存储指南。

对离散代码级问题,你可能会希望咨询苹果开发者技术支持。请务必:

——包括完整的细节,你的排斥问题

——准备任何symbolicated崩溃记录,截屏和步骤来再现问题当DTS工程师跟踪。

 

For information on how to symbolicate and read a crash log, please see Tech Note TN2151 Understanding and Analyzing iPhone OS Application Crash Reports.

 

If you have difficulty reproducing this issue, please try testing the workflow as described in <https://developer.apple.com/library/ios/qa/qa1764/>Testing Workflow with Xcode's Archive feature".

关于如何symbolicate和读一个崩溃的日志,请见技术注意TN2151理解和分析iPhone OS应用程序崩溃报告。

 

如果你很难繁殖这个问题,请尝试测试工作流中描述的

< https://developer.apple.com/library/ios/qa/qa1764/ >测试工作流与Xcode的存档特性

 

 

 

 

Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.

https://developer.apple.com/library/ios/#qa/qa1719/_index.html

 

Technical Q&A QA1764:Testing Workflow with Xcode's Archive feature

http://developer.apple.com/library/ios/#qa/qa1764/_index.html

 

https://developer.apple.com/library/ios/#technotes/tn2008/tn2151.html

Technical Q&A QA1719

How do I prevent files from being backed up to iCloud and iTunes?

Q:  My app has a number of files that need to be stored on the device permanently for my app to function properly offline. However, those files do not contain user data and don't need to be backed up. How can I prevent them from being backed up?

我的应用程序有很多文件,需要存储在设备上为我的应用程序功能永久妥善离线。然而,这些文件不包含用户数据和不需要备份。我怎样才能防止他们被备份?

A: On iOS, apps are responsible for ensuring that only user data and not application data is backed up to iCloud and iTunes. The exact steps necessary vary between iOS version, so this QA will describe the process for each version of iOS. For more information on exactly what data should or should not be backed up, see the App Backup Best Practices section of the iOS App Programming Guide.

答:关于iOS,应用程序负责确保只有用户数据,而不是应用程序数据备份到iCloud和iTunes。确切的必要步骤不同iOS版本,所以这QA将描述这个过程对于每个版本的iOS。更多信息正是数据应该或不应该备份,请参阅应用程序备份的最佳实践部分的iOS应用程序编程指南< http://developer.apple.com/library/ios/ >。

 

Important: Apps should avoid mingling app data and user data in the same file. Doing so will unnecessarily increase backup sizes and can be considered a violation of the iOS Data Storage Guidelines.

重要:应用程序应该避免混合应用程序数据和用户数据在同一个文件中。这样做将增加不必要的备份大小,可以被看作是违反了iOS数据存储指南。

iOS 5.1 and later

Starting in iOS 5.1, apps can use either NSURLIsExcludedFromBackupKey or kCFURLIsExcludedFromBackupKey file properties to exclude files from backups. Either of these APIs is preferred over the older, deprecated approach of directly setting an extended attribute. All apps running on iOS 5.1 should use these APIs to exclude files from backups.

iOS 5.1开始,用程序可以使用< http://developer.apple.com/library/ios/ > NSURLIsExcludedFromBackupKeykCFURLIsExcludedFromBackupKey文件属性来排除文件从备份。 这两种api是优先于年长的,过时的方法直接设置一个扩展属性。所有的应用程序运行在iOS 5.1应该使用这些api来排除文件从备份。

 

Listing 1  Excluding a File from Backups on iOS 5.1

排除一个文件备份

- (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;
}

Back to Top

 

iOS 5.0.1

 

If your app must support iOS 5.0.1, you can use the following method to set the "do not back up" extended attribute. Whenever you create a file or folder that should not be backed up, write the data to the file and then call this method, passing in a URL to the file.

如果你的应用程序必须支持iOS 5.0.1,您可以使用以下方法来设置不支持扩展属性。当你创建一个文件或文件夹,不应该备份,将数据写入文件,然后调用这个方法,传入一个URL到文件。

 

 

Warning: The code that follows has been deprecated and should only be used on iOS 5.0.1 or earlier. When running in iOS 5.1, apps should use the NSURL and CFURL keys described above.

Listing 2 Setting the Extended Attribute on iOS 5.0.1

警告:后面的代码已经被弃用,只应该用于iOS 5.0.1或更早。在iOS 5.1运行时,应用程序应该使用上面描述CFURL NSURL和钥匙。

清单2设置扩展属性在iOS 5.0.1

 

#import <sys/xattr.h>

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL

{

    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

 

    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;

}

Back to Top

 

iOS 5.0

It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.

Back to Top

它不可能排除在iOS 5.0的数据备份。如果你的应用程序必须支持iOS 5.0,那么您将需要存储应用程序数据缓存来避免数据备份。iOS将会删除你的文件从缓存目录在必要的时候,所以你的应用程序将需要完全降低如果它的数据文件被删除。

 


Document Revision History

 

Date

Notes

2012-04-23

Updated for iOS 5.1

2011-11-10

-Fixed critical bug in code snippet.

 

New document that describes how an app can prevent files from being backed up to iCloud and iTunes.

 

 解决办法:

程序数据和图片、sqlite数据库---不需要云备份,(离线看需要本地数据)

用户数据(用户浏览的食谱图片、胎教音乐)---需要云备份

有临时文件就设置在  /tmp    ---缓存等临时文件,退出需要删除

 

我也遇到过,之前把所有数据都存在Documents下了,改了目录就通过了

 

 数据的问题: 11,只有用户产生的数据应该放到/Documents里,你app产生的不要放 12,下载可以重用的东西放/Library/Caches 13,临时的放/tmp,不用的时候记得删掉 14,用"do not back up"标记需要留在设备上的数据,那些没联网也可以保证使app运行的数据(别因为连不上网拿不到数据app运行不了) 他的意思,你把这个iOS Data Storage Guidelines看一遍再。


--------------------------------------------------------------------------------------------------------------------------------------------


研究一翻,找到如下的一些资料。。。

http://www.cocoachina.com/bbs/read.php?tid=86244

iOS Data Storage Guidelines 和 “do not back up”文件属性

iOS 5有了iCloud后,Apple更新了数据存储指导方针,以适应于iCloud存储,同时增加了“不要备份”文件属性,可以指定文件不备份和上传到iCloud

摘录如下,供大家参考:

iOS 数据存储指导方针

iCloud包括了备份,会通过Wi-Fi每天自动备份用户iOS设备。app的home目录下的所有东西都会被备份,除了应用Bundle本身、缓存目录和temp目录。已购买的音乐、应用、书籍、Camera Roll、设备设置、主屏幕、App组织、消息、铃声也都会被备份。由于备份通过无线进行,并且为每个用户存储在iCloud中,应用需最小化自己存储的数据数量。大文件会延长备份时间,并且消耗用户的可用iCloud空间。

为了确保备份尽可能快速高效,应用存储数据需要遵循以下指导方针:

1. 只有那些用户生成的文档或其它数据,或者应用不能重新创建的数据,才应该存储在/Documents目录下,并且会被自动备份到iCloud。

2. 可以重新下载或生成的数据,应该存储在/Library/Caches目录。例如数据库缓存文件、可下载文件(杂志、报纸、地图应用使用的数据)等都属于这一类。

3. 临时使用的数据应该存放在/tmp目录。尽管这些文件不会被iCloud备份,应用在使用完之后需要记得删除这些文件,这样才不会继续占用用户设备的空间。

4. 使用”不要备份”属性来指定那些需要保留在设备中的文件(即使是低存储空间情况下)。那些能够重新生成,但在低存储空间时仍需保留,对应用正常运行有影响,或者用户希望文件在离线时可用的文件,需要使用这个属性。无论哪个目录下的文件(包括Documents目录),都可以使用这个属性。这些文件不会被删除,也不会包含在用户的iCloud或iTunes备份中。由于这些文件一直占用着用户设备的存储空间,应用有责任定期监控和删除这些文件。

iOS 5.0.1开始支持”do not back up”文件属性,允许开发者明确地指定哪些文件应该被备份,哪些是本地缓存可以自动删除,哪些文件不需要备份但不能删除。此外,对目录设置这个属性,会阻止备份该目录和目录中的所有内容。

注意”do not back up”属性只能用于iOS 5.0.1以后版本。之前版本的应用需要存储数据到/Library/Caches目录才能避免被备份。由于老的系统忽略这个属性,你需要确保应用在所有iOS版本中,都遵循上面的iOS Data Storage Guidelines。

数据处理分类
com.apple.MobileBackup文件属性就是iOS 5.0.1引入的”do not back up”特性,用于指定文件或目录不需要备份(不管在文件系统的什么位置)。通过使用这个新的文件属性,并且将文件存放在指定的目录下,文件可以分为以下四种数据类型:s.

关键数据
这些是用户创建的数据,或其它不能重新生成的数据。应该存放在/Documents目录下,并且不应该标记为”do not backup”属性。关键数据在低存储空间时也会保留,而且会被iCloud或iTunes备份。

缓存数据
可以重新下载或生成的数据,而且没有这些数据也不会妨碍用户离线使用应用的功能。缓存数据应该保存在/Library/Caches目录下。缓存数据在设备低存储空间时可能会被删除,iTunes或iCloud不会对其进行备份。

临时数据
应用需要写到本地存储,内部使用的临时数据,但不需要长期保留使用。临时数据应该保存在/tmp目录。系统可能会清空该目录下的数据,iTunes或iCloud也不会对其进行备份。应用在不需要使用这些数据时,应该尽快地删除临时数据,以避免浪费用户的存储空间。

离线数据
可以下载,或重新创建,但用户希望在离线时也能访问这些数据。离线数据应该存放在/Documents目录或/Library/Private Documents目录,并标记为”do not backup”属性。这两个位置的数据在低存储空间时都会保留,而”do not backup”属性会阻止iTunes或iCloud备份。应用不再需要离线数据文件时,应该尽快删除,以避免浪费用户的存储空间。ce.

设置Do Not Backup扩展属性
注意:”do not backup”扩展属性可以添加到任何文件或目录,在旧版本的系统中也能够设置。但旧系统仍然会备份这些文件,一旦设备更新到iOS 5.0.1,这些文件会被重新正确地配置。

使用下面方法来设置”do not back up”扩展属性。当你创建不需要备份的文件或目录时,向文件写入数据,然后调用下面方法,并传递一个文件URL。

http://blog.csdn.net/nogodoss/article/details/8506778

http://blog.sina.com.cn/s/blog_9cd1705d0101eerp.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值