Xcode4 - where to look for sqlite file created by master data

I just started using basic data. I want to configure a pre-populated db. I read somewhere that the main data creates a sqlite file when the application starts for the main data. I don’t know where to look for him, though.

I followed the instructions for this blog , but did not find the sqlite file in the specified directory /Users/<Username>/Library/Application Support/iPhone Simulator/User/Application/<Application GUID>/Documents/<database name.sqlite> , but also in the application directory.

here is my code for persistentCoordinator.

 - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (__persistentStoreCoordinator != nil) { return __persistentStoreCoordinator; } NSString *storePath = [[[self applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"coredata.sqlite"]; NSFileManager *fileManager = [NSFileManager defaultManager]; if (![fileManager fileExistsAtPath:storePath]) { NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"coredata" ofType:@"sqlite"]; if (defaultStorePath) { [fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL]; } } NSURL *storeURL = [NSURL fileURLWithPath:storePath]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; NSError *error = nil; __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return __persistentStoreCoordinator; } 
+7
source share
4 answers

These files are in ~/Library/Application Support/iPhone Simulator/[SDK version]/Applications/[App GUID]/Documents for me, for both Xcode 3 and Xcode 4.

If you have multiple SDKs, be sure to check out all the SDK version directories for your application.

+16
source

For me it was at whatMuregSaid / [Application Guid] / Library / Application Support / [AppName] /filename.sqlite

+1
source

Follow these steps:

  • In your applicationDocumentsDirectory function in AppDelegate.swift add this code:

    let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)

    // Look for this in the console, this will print out the location of the sqlite database, which you can then open with an SQLite viewer

    print("urls.last \(urls.last)")

  • Look for it in the console, it will print the location of the sqlite database, open a terminal and open whatever_the_location_path_was

  • Download SQLite Viewer http://sqlitebrowser.org/

  • Right-click the yourapp.sqlite file in the folder, select Open Using the sqlitebrowser that you downloaded

Hooray!

+1
source

hope this helps you a little more

  • / Users / Username / then press cmd + shift + G and write / Users / Username / Library. Now you will see the library folder after loading it into the support application / iPhone Simulator / 7.1 (or 7.1-64) / Application / F84D4CC8- 326E-4A2E-8A37-F1A755D6FCC4 / Documents you will see three files and one .sqlite file.

  • To see the structure and other information of this sqlite file, the most efficient way is to use SQLITE MANAGER (add firefox https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ ) add it and then click TOOL.

0
source

All Articles