App rejected for storing database in Documents dir

2019-05-04 07:33发布

My app was recently rejected from the app store for storing data in the Documents directory. I had moved it there because with the latest change, the db must now be writeable - it's no longer read-only.

In researching the solution, I've read that it's actually preferable to use NSLibraryDirectory. Is this so, and more importantly, will that address Apple's concerns? Their complaint is that the app lets the user download to much content (it doesn't let the user download any unless you count the db), and that it's storing "too much data" in the "incorrect location." The data is 8 mb, but could grow to about 10 or 12 mb max.

4条回答
老娘就宠你
2楼-- · 2019-05-04 08:12

Actually its because of iCloud.

using iCloud, Application's document directory is synced to cloud and to other devices and hence Apple want developers to store only that data in document directory which they want to sync with iCloud.

I came to know this form one of my friends who work @ Apple California and I'm not really sure if this material is on Apple's documentation.

查看更多
趁早两清
3楼-- · 2019-05-04 08:14

A product I wrote a year ago uses CoreData (with a SQLite data store). This database file is stored in ~/Library/Application Support//. This was approved by Apple without issue.

"Application Support" does not exist in ~/Library, so you will need to create it.

Documents is not a great place to store your database file for several reasons. Apple has their reasons, since they rejected your app. Another reason is that the Documents directory is accessible by the user (via iTunes), and unless the user deleting your database file is no big deal to the operation of your app, it is best to put it where they can not do anything with it directly and/or inadvertently.

查看更多
▲ chillily
4楼-- · 2019-05-04 08:20

You can still put those files in the Documents folder, you just have to give them an attribute that lets the file system know not to back them up to the iCloud

This is a great example of how to do so on different iOS versions

查看更多
Fickle 薄情
5楼-- · 2019-05-04 08:23

I had this issue with an update to a suite of apps I develop the other week. The funny thing was that only five of the seven apps (exactly the same code base) were rejected.

I believe the issue in my case was duplicating assets from the .app bundle into ~/Documents.

My first attempt to comply with their new storage guidelines was to implement the do not backup switch on the files I was copying into ~/Documents. No deal with that so I had to change my implementation to not copy the data at all. The apps were promptly approved.

Your implementation is probably different but in my experience Apple no longer likes you copying things from the app bundle into ~/Documents, as it could be duplicating data unnecessarily (in their view).

They suggest copying into ~/Caches (or whatever it is), but this can be cleared in low storage situations and may not be right for your case either.

Hope that helps.

查看更多
登录 后发表回答