3

I have sqlite db using FMDB wrapper that puts the db in documents folder on launch. User can also upload files through itunes in documents folder.

But appstore rejected the app as following:

When file sharing is enabled, the entire Documents folder is used for file sharing. Files that that are not intended for user access via the file sharing feature should be stored in another part of your application's bundle. If your application does not require the file sharing feature, the UIFileSharingEnabled key in the Info.plist should not be set to true.

Is there any workaround to put db in some place or restrict in documents folder so that it gets approved by apple.

  • 1
    You could put them in the Library folder – J Max Jan 26 '13 at 14:24
  • See [Where You Should Put Your App’s Files](http://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW28) of the _File System Programming Guide._ – Rob Jan 26 '13 at 15:17

1 Answers1

4

You will have to change the path of the file from document directory to Cache Directory:

Search for this in your code 'NSDocumentDirectory' and replace with 'NSCachesDirectory' and let everything be same then your database will auto moved to cache directory on launch and apple won't reject it as well. :)

Hope it helps.

EDIT: To set your own database path, pass 'cacheDirectoryPath' string in your code instead of your path, below code will create this cacheDirectoryPath for you:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *cacheDirectoryPath = [paths objectAtIndex:0];
Reno Jones
  • 1,979
  • 1
  • 18
  • 30
  • 2
    The caches directory is a bad choice if the database is not read-only. The caches directory is not backed up and it won't survive an app update. IF the data is writable, use `NSApplicationSupportDirectory`. Note that this directory must be created first. – rmaddy Jan 26 '13 at 18:23
  • Thanks, my db is not read-only, so NSApplicationSupportDirectory would be a better choice. – Hassan Waheed Jan 27 '13 at 06:42
  • Can someone explain to me where to put that code in? Should it be in the appdelegate? @HassanWaheed – linuxer Oct 02 '14 at 20:50