109

Typically, the sqlite store file for core data apps is located in

Library>Application Support>iPhone Simulator>7.1(or whichever version you are using)>Applications>(Whichever folder contains your app)>Documents

folder, but I can't find it in IOS 8. I would assume they would just add an 8.0 folder inside the iPhone Simulator folder, but it's not there. Has anybody been able to locate it?

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
enlyte
  • 2,757
  • 3
  • 13
  • 13
  • 2
    I'm Pretty sure your question is the duplicate, considering I asked it over a week before yours was asked. It would be appreciated if you let me get the credit for this question, considering it's the first question I've ever asked, and it seems like you already have a reputation @HenryGlendening – enlyte Jun 19 '14 at 19:15
  • Check out this how to check dbpath http://stackoverflow.com/a/27358291/3840428 – Nagarjun Dec 08 '14 at 13:03
  • Follow this one ...http://stackoverflow.com/questions/24290989/xcode-6-iphone-simulator-application-support-location/27358291#27358291 – Tunvir Rahman Tusher Dec 13 '14 at 16:51
  • 2
    Does anybody know how to get the CoreData files from the actual device? I used to do this via iTunes in older versions of Xcode, but since Xcode 8 / iOS10 I don't think the CoreData files are stored in the documents directory of the app, hence not visible in iTunes. Is there a way to get the CoreDate files from the device on your computer? – Bocaxica Sep 29 '16 at 07:43
  • 1
    I do not know why they continue to move this. They should put it somewhere and just leave it. – RegularExpression Nov 02 '16 at 21:43

23 Answers23

144

I managed to locate the sqlite file, and its in this path now:

Library/Developer/CoreSimulator/Devices/(numbers and letters)/data/Containers/Data/Application/(numbers and letters)/Documents/

(numbers and letters) stands for a folder that would be unique to your app/computer, but would look like this: 779AE2245-F8W2-57A9-8C6D-98643B1CF01A

I was able to find it by going into appDelegate.m, scrolling down to the

- (NSURL *)applicationDocumentsDirectory 

method, and NSLogging the return path, like this:

// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory
{
    NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory  inDomains:NSUserDomainMask] lastObject]);

    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
 }

This will give you your unique path, making it easier for you, because it is tricky locating it with the 2 unnamed folders/strings of letters and numbers.

Swift 4.2:

let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
print(paths[0])
Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
enlyte
  • 2,757
  • 3
  • 13
  • 13
  • 4
    Use `xcrun simctl list` to get the list of simulator names and their UUIDs. – Sandy Chapman Mar 06 '15 at 12:45
  • 2
    Note that if you use a shared database for an app group (for example when you are using an extension) the path is Library/Developer/CoreSimulator/Devices/$number/data/Containers/Shared/AppGroup/$number/Name.sqlite – andreacipriani Oct 30 '15 at 11:37
  • 19
    Note that, in **2019**,`Library/Developer/CoreSimulator/Devices/(numbers and letters)/data/Containers/Data/Application/(numbers and letters)/Documents/` is no longer true. Now you find the .sqlite and related two files in `Library/Developer/CoreSimulator/Devices/(numbers and letters)/data/Containers/Data/Application/(numbers and letters)/Library/Application Support/` – Gang Fang Apr 27 '19 at 08:57
  • @GangFang I'm trying to convert my Objective C code which is build in Xcode 7 to the latest swift version and create new project, so how I can migrate this two different .sqlite file into once place. – Sanjay Shah Feb 28 '20 at 11:16
  • Try `NSLog(@"APPLICATION SUPPORT DIRECTORY: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject]);` @Gang Fang 's pointer to the change in directory structure highlights the need to change the search location from `NSDocumentDirectory` – MiltsInit Mar 25 '21 at 11:45
138

None of the answers mentioned the simplest way to actually get the location of the DB file.

It doesn't even require you to modify your source code, as it's a simple run time switch in XCode.

  1. Choose Edit Scheme... next to the Run button.

    edit scheme

  2. Select Run / Arguments and add the following two options:

    -com.apple.CoreData.SQLDebug 1
    -com.apple.CoreData.Logging.stderr 1
    

    option

  3. Run the app, and you'll see in the logs:

    logs

hyperknot
  • 13,454
  • 24
  • 98
  • 153
  • 4
    This is indeed the simplest and best solution. Thanks! – Omid Ariyan Jan 08 '18 at 11:51
  • For me the log not appears, you can help me? – Augusto Mar 19 '18 at 01:40
  • @Augusto I cannot help you here, but if you ask a new question about it people can probably answer it and help you. – hyperknot Mar 19 '18 at 14:57
  • 1
    Great answer! This should be the accepted answer. Also is there any way that you know of to change the color of this output in the console, other than through Xcode preferences? It would be nice if it stood out a bit more –  Dec 20 '19 at 21:53
  • Thank you for the hint! Path changes constantly, for me now (iOS 13.3.1) path is /Users/***/Library/Developer/CoreSimulator/Devices/A91CEB1C-B15D-46B5-9B83-DB22056DEFD1/data/Containers/Shared/AppGroup/B835599A-CA36-432F-871A-17EDA181CC54/ So it's better to get it from CoreData debug information rather than trying to guess yourself. – AlKir Feb 24 '20 at 11:50
  • Super powerful feature! Thank U! – Dmytro Yashchenko Jul 10 '23 at 12:08
52

Try this Simple 3 Step

  1. Copy the following code in didFinishLaunchingWithOptions your appdelegate.m and add a break point before the NSLog()

    (BOOL)application:(UIApplication *)application  
    
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSLog(@"%@",[paths objectAtIndex:0]);
     }
    

Or in Swift:

let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
print(paths[0])

enter image description here

2.Open Finder->Go -> Go to folder and paste the path copied from step 1

enter image description here

3. Yah!!! You are in your Destination.

Ender Doe
  • 162
  • 1
  • 10
Tunvir Rahman Tusher
  • 6,421
  • 2
  • 37
  • 32
  • 2
    For swift3 use: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true) – Yohst Dec 10 '16 at 22:22
40

If your app is using Core Data, it's just a matter of searching for the sqlite file in Terminal:

find ~ -name app_db_file_name.sqlite

The results will list the full path to the simulator folders containing your app.

DiscDev
  • 38,652
  • 20
  • 117
  • 133
  • 2
    @AlexWei I wish that Apple would add a button on the File menu to "Reveal Simulator documents folder in finder" or something similar. Seems ridiculous that it's still not there, considering they keep changing where they are storing files... – DiscDev Nov 20 '14 at 17:46
  • 1
    In case others are interested, I added this command as an alias to my .profile: `alias myapp_simulator_db="find ~/Library/Developer/CoreSimulator/Devices -name MyApp.sqlite"`. Its handy when you need to repetitively run this command. – toast Dec 11 '16 at 07:39
  • sudo find ~ -name app_db_file_name.sqlite helped me – Qadir Hussain May 02 '17 at 10:37
21

I hacked this one-liner (Gist): find ~/Library/Developer/CoreSimulator/Devices/ -name device.plist -exec sh -c "/usr/libexec/PlistBuddy -c \"print UDID\" '{}' | tr '\n' ' '" \; -exec sh -c "/usr/libexec/PlistBuddy -c \"print name\" '{}' | tr '\n' ' '" \; -exec sh -c "/usr/libexec/PlistBuddy -c \"print runtime\" '{}' | sed -n 's/com\.apple\.CoreSimulator.SimRuntime\.\(.*\)/\1/p'" \;

This prints:

14F313C8-3813-4E38-903E-2010C136B77B iPad Retina iOS-8-0
1F6B82A2-C467-479A-8CAF-074BE507AC8E iPad Air iOS-8-0
2DA83944-BE5D-4342-B330-08F67A932D8C iPad 2 iOS-7-1
48703432-A5C5-4606-9369-0D21B53EB1E8 iPhone 4s iOS-7-1
4AFB71CC-6752-4F9A-A239-4DC9CA53A8B8 iPhone 5s iOS-8-0
53A65771-DF50-4A5C-A8D2-4D1C3A5D0F60 iPhone 5 iOS-7-1
6B97C174-5914-4E89-8D17-943F0E2703BA iPhone 5 iOS-8-0
6C2DF3E9-FA26-4391-8B66-72E1467D6297 iPad 2 iOS-8-0
7F85E299-A3C2-4704-8B44-2984F6F995F5 iPad Retina iOS-7-1
8B9EDFFD-2240-476B-88AD-06ABE8F9FF51 iPhone 6 Plus iOS-8-0
97691E5D-5C38-4875-8AA7-C2B1E4ABCBB5 Resizable iPhone iOS-8-0
9BBF3408-6CA4-4CE0-BD4E-B02001F1262B iPhone 5s iOS-7-1
C9237847-F0AA-44BC-A74E-C08C2E0F7A6C Resizable iPad iOS-8-0
CC44C1BA-F39C-4410-AE34-4ABBD7806D45 iPad Air iOS-7-1
CDF4D811-5011-4464-8291-5CDA378375EA iPhone 6 iOS-8-0
E77DE00C-E244-4F25-A5E2-E6581614D5A2 iPhone 4s iOS-8-0

Update:

As someone pointed out here, it is also possible to run xcrun simctl list devices to get a similar result:

== Devices ==
-- iOS 7.0 --
-- iOS 7.1 --
    iPhone 4s (48703432-A5C5-4606-9369-0D21B53EB1E8) (Shutdown)
    iPhone 5 (53A65771-DF50-4A5C-A8D2-4D1C3A5D0F60) (Shutdown)
    iPhone 5s (9BBF3408-6CA4-4CE0-BD4E-B02001F1262B) (Shutdown)
    iPad 2 (2DA83944-BE5D-4342-B330-08F67A932D8C) (Shutdown)
    iPad Retina (7F85E299-A3C2-4704-8B44-2984F6F995F5) (Shutdown)
    iPad Air (CC44C1BA-F39C-4410-AE34-4ABBD7806D45) (Shutdown)
-- iOS 8.1 --
    iPhone 4s (0763EF65-DD0D-4FAD-84C7-2DE63D416526) (Shutdown)
    iPhone 5 (868ED444-8440-4115-AF37-F419CC682D2F) (Shutdown)
    iPhone 5s (E0455E5D-7315-4EC8-B05E-76284728244C) (Shutdown)
    iPhone 6 Plus (72554908-FF99-4B8F-9B87-65255ED08CFC) (Shutdown)
    iPhone 6 (32AA8133-53A4-4BE0-8CE5-0C7A87E81CAF) (Shutdown)
    iPad 2 (4AF84DE8-CBA2-47AE-A92A-0C0CEF9F41F8) (Booted)
    iPad Retina (69238B44-AAFD-4CD5-AAEA-C182D0BC300D) (Shutdown)
    iPad Air (E580AD99-0040-4EC1-B704-0C85567E6747) (Shutdown)
    Resizable iPhone (32E872FC-6513-41AB-A5B9-B23EB7D10DC8) (Shutdown)
    Resizable iPad (99997922-4A9F-4574-9E3E-EF45F893F4A2) (Shutdown)
Alexander
  • 1,495
  • 2
  • 19
  • 24
19

If you're using Swift, this will return the document directory's absolute path:

func applicationDirectoryPath() -> String {
    return NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last! as String
}
Mike Rapadas
  • 4,613
  • 2
  • 28
  • 21
13

I wrote a bash script for finding the location of your Application folder and the Application data folder within a simulator, you can download it here. Once you have unzipped the script you can navigate to the folder the script is in and use it. If you call it with no options it will give you a list of installed iOS simulators. You can then use the options to find your program. Writing:

./simulatorAppFolders -s "iPad Air" -i iOS-8-0 -a <MyApp>

will find the application folder and home area folder for your app on the iPad Air iOS 8 simulator. Here's an example:

MacBook-Air:_posts user$ ./simulatorAppFolders -s "iPad Air" -i iOS-8-0 -a MyApp
App folder = /Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0/data/Containers/Bundle/Application/8F64CD7F-A227-43D6-98AC-41D3919827CB
dataFolder = /Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0/data/Containers/Data/Application/96C40A21-5A5C-4399-839C-B155B8A72932

Update

There's an update to the original script which allows you to search based on the device type using a -d option. I've also written another script which makes a series of sensibly named folders so you can find your application and application documents. This script will make a folder called iOS_SIMULATORS in your home area and you can easily navigate to your application from there.

James Snook
  • 4,063
  • 2
  • 18
  • 30
7

I was able to locate simulators folder with the next console output:

NSLog(@"app dir: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

in my case it was (Xcode 6 beta)

app dir: file:///Users/user/Library/Developer/CoreSimulator/Devices/D00C56D4-DDA3-47B0-9951-27D3B9EC68E8/data/Applications/6ABF3E54-37F5-4AD1-A223-F7467F601FB6/Documents/
vir us
  • 9,920
  • 6
  • 57
  • 66
6

Based on Michaels answers, this is for Swift 3

    func applicationDirectoryPath() -> String {
        return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last! as String
    }
Jochen Bedersdorfer
  • 4,093
  • 24
  • 26
6

After new updates of Xcode I found that the sql files are now stored in new folder /Library/Application Support this could be a unique situation but if you did not found the sql files in document folder search them here:

~/Library/Developer/CoreSimulator/Devices/[@device_id@]/data/Containers/Data/Application/[@application_id@]/Library/Application Support/

before it was stored in Documents folder:

~/Library/Developer/CoreSimulator/Devices/[@device_id@]/data/Containers/Data/Application/[@application_id@]/Documents/

Nazir
  • 1,945
  • 24
  • 27
5

For Swift 3.0

let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
print(paths[0])

you can get location of Coredata in Xcode 8.2

Sunil M.
  • 554
  • 5
  • 17
4

For SWIFT 3 :

Copy paste this code in didFinishLaunchingWithOptions

 print(NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).last! as String)
Sandu
  • 436
  • 4
  • 8
  • This helped me. but when I try to goto that path via terminal it says: No such file or directory but when I try to goto folder option it actually exists. – Qadir Hussain May 02 '17 at 10:46
  • This worked for me on OSX. I needed to go 1 more directory within the "Application Support" directory named to fine the .sqlite file. – Jacksonsox Nov 19 '17 at 14:12
3

For swift 3

print(NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).last! as String)
slfan
  • 8,950
  • 115
  • 65
  • 78
Andrew Shon
  • 99
  • 2
  • 4
3

swift 4.x

You can reliably fetch it from your NSPersistentContainer description.

for description in container.persistentStoreDescriptions {
    print("db location: \(description.url!)")
}
Munhitsu
  • 1,014
  • 1
  • 9
  • 16
2

Like James Snook I created my own script to provide easier access to the simulator apps. I think it can be handy to many people getting here, other than me.

Unlike his script, mine is not a search tool, it creates a complete (and human readable) folder structure with all the devices/runtimes, and puts soft links to the apps in them.

You can get it in this Gist.

Run it every time you install an app in the simulator, or just run it every time you are going fetch an app for any reason (it will update, and open the devices folder in Finder).

Community
  • 1
  • 1
fbeeper
  • 238
  • 2
  • 10
  • You can adapt this script to automate some things. But I must say that [this GUI app](http://simpholders.com) that I just found sounds as a really useful alternative if you just want access to the app folders :) – fbeeper Sep 16 '14 at 18:03
  • This is also quite nice but I prefer the 2nd script posted by James Snook as it creates soft links to the data directories as well. – David Hersey Jan 19 '16 at 22:50
2

For iOS 10.0+ you can use persistentContainer.persistentStoreCoordinator.persistentStores.first?.url

I have created the Utility function that copies the sqlite file to your desired location (works only for simulator).

You can use it like

import CoreData


let appDelegate = UIApplication.shared.delegate as! AppDelegate
UTility.getSqliteTo(destinationPath: "/Users/inderkumarrathore/Desktop", persistentContainer: appDelegate.persistentContainer)

If you've already access to sqlite, shm and wal files then run the commands in the terminal to merge the WAL file into the sqlite file.

$ sqlite3 persistentStore
sqlite> PRAGMA wal_checkpoint;
Press control + d

After running the above commands you can see the data in your sqlite file.


Here is definition of utility method for

/**
 Copies the sqlite, wal and shm file to the destination folder. Don't forget to merge the wal file using the commands printed int the console.
 @param destinationPath Path where sqlite files has to be copied
 @param persistentContainer NSPersistentContainer
*/
public static func getSqliteTo(destinationPath: String, persistentContainer: NSPersistentContainer) {
  let storeUrl = persistentContainer.persistentStoreCoordinator.persistentStores.first?.url

  let sqliteFileName = storeUrl!.lastPathComponent
  let walFileName = sqliteFileName + "-wal"
  let shmFileName = sqliteFileName + "-shm"
  //Add all file names in array
  let fileArray = [sqliteFileName, walFileName, shmFileName]

  let storeDir = storeUrl!.deletingLastPathComponent()

  // Destination dir url, make sure file don't exists in that folder
  let destDir = URL(fileURLWithPath: destinationPath, isDirectory: true)

  do {
    for fileName in fileArray {
      let sourceUrl = storeDir.appendingPathComponent(fileName, isDirectory: false)
      let destUrl = destDir.appendingPathComponent(fileName, isDirectory: false)
      try FileManager.default.copyItem(at: sourceUrl, to: destUrl)
      print("File: \(fileName) copied to path: \(destUrl.path)")
    }
  }
  catch {
    print("\(error)")
  }
  print("\n\n\n ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NOTE ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~\n")
  print("In your terminal run the following commands to merge wal file. Otherwise you may see partial or no data in \(sqliteFileName) file")
  print("\n-------------------------------------------------")
  print("$ cd \(destDir.path)")
  print("$ sqlite3 \(sqliteFileName)")
  print("sqlite> PRAGMA wal_checkpoint;")
  print("-------------------------------------------------\n")
  print("Press control + d")      
}

For

/**
 Copies the sqlite, wal and shm file to the destination folder. Don't forget to merge the wal file using the commands printed int the console.
 @param destinationPath Path where sqlite files has to be copied
 @param persistentContainer NSPersistentContainer
 */
+ (void)copySqliteFileToDestination:(NSString *)destinationPath persistentContainer:(NSPersistentContainer *)persistentContainer {
  NSError *error = nil;
  NSURL *storeUrl = persistentContainer.persistentStoreCoordinator.persistentStores.firstObject.URL;
  NSString * sqliteFileName = [storeUrl lastPathComponent];
  NSString *walFileName = [sqliteFileName stringByAppendingString:@"-wal"];
  NSString *shmFileName = [sqliteFileName stringByAppendingString:@"-shm"];
  //Add all file names in array
  NSArray *fileArray = @[sqliteFileName, walFileName, shmFileName];

  // Store Directory
  NSURL *storeDir = storeUrl.URLByDeletingLastPathComponent;

  // Destination dir url, make sure file don't exists in that folder
  NSURL *destDir = [NSURL fileURLWithPath:destinationPath isDirectory:YES];

  for (NSString *fileName in fileArray) {
    NSURL *sourceUrl = [storeDir URLByAppendingPathComponent:fileName isDirectory:NO];
    NSURL *destUrl = [destDir URLByAppendingPathComponent:fileName isDirectory:NO];
    [[NSFileManager defaultManager] copyItemAtURL:sourceUrl toURL:destUrl error:&error];
    if (!error) {
      RLog(@"File: %@ copied to path: %@", fileName, [destUrl path]);
    }
  }


  NSLog(@"\n\n\n ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NOTE ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~\n");
  NSLog(@"In your terminal run the following commands to merge wal file. Otherwise you may see partial or no data in %@ file", sqliteFileName);
  NSLog(@"\n-------------------------------------------------");
  NSLog(@"$ cd %@", destDir.path);
  NSLog(@"$ sqlite3 %@", sqliteFileName);
  NSLog(@"sqlite> PRAGMA wal_checkpoint;");
  NSLog(@"-------------------------------------------------\n");
  NSLog(@"Press control + d");
}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
2

If you haven't specified any directory then you can use the below code to print default directory:

print(NSPersistentContainer.defaultDirectoryURL())

Ashutosh Shukla
  • 358
  • 5
  • 14
1

Swift 4.2

let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
        print(paths[0])
Amin.MasterkinG
  • 805
  • 1
  • 12
  • 23
Divesh singh
  • 409
  • 4
  • 12
1

Swift 4.2

I have created an extension for the NSPersistentStoreDescription

import CoreData

extension NSPersistentStoreDescription {
    func getDatabaseLocation() -> String? {
        return self
            .url?
            .absoluteString
            .replacingOccurrences(of: "file://", with: "") // Remove file suffix
            .replacingOccurrences(of: "%20", with: "\\ ") // Make the spaces to support terminal paste
    }
}

Then I use it when I initialize the NSPersistentContainer

lazy var persistentContainer: NSPersistentContainer = {

        let container = NSPersistentContainer(name: "CoreDataDemo")
        
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            
            #if DEBUG
            debugPrint(storeDescription.getDatabaseLocation() ?? "No database location")
            #endif
            
            if let error = error as NSError? {
                assertionFailure("Unresolved error \(error), \(error.userInfo)")
            }
        })
        
        return container
    }()
0

Swift 4.x

    let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
    print(paths[0])
Nahsrad
  • 1
  • 1
0
  1. Chose the edit Scheme enter image description here

  2. Select Run / Arguments and add the following two options:- Add two Aurgument

-com.apple.CoreData.SQLDebug 1 -com.apple.CoreData.Logging.stderr 1

enter image description here

  1. You will get in console of XCode enter image description here

  2. Click on -> Finder -> then Click GO

  3. List item

  4. copy and paste

  5. List item

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 14 '22 at 11:51
  • This answer is already answered for the question https://stackoverflow.com/a/47402447/901715 – Eldhose Jul 05 '23 at 10:05
-1

Swift 3.x

Locate didFinishLaunchingWithOptions function in your AppDelegate file and past this code there.

let path = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)
print("\(path)")
Chetan
  • 881
  • 14
  • 22
-2

You can use following code.

   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    **print(persistentContainer.persistentStoreDescriptions)**
    return true
}

It will print location of core data persistent storage i.e sqlite

Piyush
  • 1,156
  • 12
  • 20