title: Can't open sqlite DB from iOS app
body: <p>I'm relatively new to iOS development and it is my first time trying to use the <code>CoreData.framework</code>.</p>
  
  <p>I created a very simple DB with "<a href="http://sqlitebrowser.org/" rel="nofollow">sqlitebrowser</a>" and copied it into my project in XCode. I can see the file is included in the app bundle. I tried to access the DB in the <code>AppDelegate</code> class, following method:</p>
  
  <pre><code>- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
      if (_persistentStoreCoordinator != nil) {
          return _persistentStoreCoordinator;
      }
  
      //For now using the `SQLite` store generate manually. Make sure to open the
      //store in read only mode since we cannot modify files in the bundle.
  
      NSURL *storeURL = [[NSBundle mainBundle] URLForResource:@"MatchWatcher" withExtension:@"sqlite"];
      //Should be like below
      NSDictionary *storeOptions = @{NSReadOnlyPersistentStoreOption:@YES, NSSQLitePragmasOption: @{@"journal_mode":@"DELETE"} };
  //    NSDictionary *storeOptions = @{NSSQLitePragmasOption: @{@"journal_mode" : @"DELETE"} };
      NSError *error = nil;
      _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
      if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                                configuration:nil
                                                          URL:storeURL
                                                      options:storeOptions
                                                        error:&amp;error]) {
          NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
      }
  
      return _persistentStoreCoordinator;
  }
  </code></pre>
  
  <p>As you can see, I try to use the storeOptions variable that includes the ReadOnly opening of the DB, but this gives me the following exception:</p>
  
  <blockquote>
    <p>2015-07-06 14:15:18.372 MatchWatcher[27495:3849154] CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/john/Library/Developer/CoreSimulator/Devices/F8C9B7DC-3C1D-495C-8FB6-80A9EA5976BB/data/Containers/Bundle/Application/CA64DE15-428B-4356-BB2B-066258E5FBAE/MatchWatcher.app/MatchWatcher.sqlite options:{
        NSReadOnlyPersistentStoreOption = 1;
        NSSQLitePragmasOption =     {
            "journal_mode" = DELETE;
        };
        } ... returned error Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x7fa38a73cbb0 {NSUnderlyingException=Cannot create a new database file with the read only option at path: /Users/john/Library/Developer/CoreSimulator/Devices/F8C9B7DC-3C1D-495C-8FB6-80A9EA5976BB/data/Containers/Bundle/Application/CA64DE15-428B-4356-BB2B-066258E5FBAE/MatchWatcher.app/MatchWatcher.sqlite} with userInfo dictionary {
        NSUnderlyingException = "Cannot create a new database file with the read only option at path: /Users/john/Library/Developer/CoreSimulator/Devices/F8C9B7DC-3C1D-495C-8FB6-80A9EA5976BB/data/Containers/Bundle/Application/CA64DE15-428B-4356-BB2B-066258E5FBAE/MatchWatcher.app/MatchWatcher.sqlite";
        }
        2015-07-06 14:15:18.373 StockWatcher[27495:3849154] Unresolved error Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x7fa38a73cbb0 {NSUnderlyingException=Cannot create a new database file with the read only option at path: /Users/john/Library/Developer/CoreSimulator/Devices/F8C9B7DC-3C1D-495C-8FB6-80A9EA5976BB/data/Containers/Bundle/Application/CA64DE15-428B-4356-BB2B-066258E5FBAE/MatchWatcher.app/MatchWatcher.sqlite}, {
        NSUnderlyingException = "Cannot create a new database file with the read only option at path: /Users/john/Library/Developer/CoreSimulator/Devices/F8C9B7DC-3C1D-495C-8FB6-80A9EA5976BB/data/Containers/Bundle/Application/CA64DE15-428B-4356-BB2B-066258E5FBAE/MatchWatcher.app/MatchWatcher.sqlite";
        }</p>
  </blockquote>
  
  <p>Any ideas of what I'm doing wrong? Some help would be appreciated! Thanks.</p>