248

I have a SQLite DB that I'm using to store app data, and I could do with taking a look inside it to debug a problem I'm having - but where does the iPhone Simulator store its data, typically?

benzado
  • 74,658
  • 20
  • 105
  • 133
Codebeef
  • 41,810
  • 20
  • 83
  • 116

21 Answers21

303

For Xcode6+/iOS8+

~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Containers/Data/Application/[AppID]/

Accepted answer is correct for SDK 3.2 - SDK 4 replaces the /User folder in that path with a number for each of the legacy iPhone OS/iOS versions it can simulate, so the path becomes:

~/Library/Application Support/iPhone Simulator/[OS version]/Applications/[appGUID]/

if you have the previous SDK installed alongside, its 3.1.x simulator will continue saving its data in:

~/Library/Application Support/iPhone Simulator/User/Applications/[appGUID]/

dsmudger
  • 3,401
  • 1
  • 14
  • 18
  • 6
    `cd ~/Library/Application\ Support/iPhone\ Simulator/` – Robert Jan 09 '14 at 11:03
  • 190
    Rather than searching in the finder for which GUID is yours, note pisca46's answer below: Just type `po NSHomeDirectory()` in the debugger. Cut and paste into Go>Go To Folder (Cmd-Shift-G). – mackworth May 30 '14 at 16:14
  • I'm a little bit concerned that when I launch the simulator it says 8.2, but when I look in this folder, the only version number I see is 7.1. That makes me worry that I'm looking in the wrong place. – bugloaf Apr 29 '15 at 20:58
  • 1
    @bugloaf [See this question](http://stackoverflow.com/questions/25198840/document-directory-path-of-ios-8-beta-simulator) or [answer below](http://stackoverflow.com/a/25191335/42078) – Raviprakash May 05 '15 at 13:55
  • 4
    It's hard to emphasis how much simpler, more convenient, less error prone and less frustrating [this answer](http://stackoverflow.com/a/23200867/2547229) is (as recommended in mackworth's comment above). You can simply add a line to `NSLog` this in your `AppDelegate`'s `didFinishLaunchingWithOptions:`, or you can `po NSHomeDirectory()` from the debugger. In either case, copy the string and open it in the finder with `Cmd+Shift+G`. This works better because you are **asking** with a standard command instead of needing to _know_ something that changes. – Benjohn Jan 05 '17 at 14:31
  • cool tip: the `[AppID]` changes each time you build the app. But if you drag that `[AppID]` folder into your dock it will update the folder location whenever it changes. – BigHeadCreations Oct 25 '18 at 16:40
  • @mackworth your answer is a lifesaver. I have so many simulators installed on my device and i have no idea where to get started. Most of the answers got me nowhere but your comment did the trick. Thanks a lot! – A. K. Nov 11 '19 at 23:26
  • If you are not running your App, you can find your **Device ID** from Xcode > "Devices and Simulators", then you can find your **AppFolder** by run the command `find [DeviceFolder] -name [AppName] -maxdepth 3`, where the **AppName** is probably your project name. – DawnSong Nov 21 '19 at 09:06
104

There is another (faster?) way to find where your app data is without Terminal:

  1. Launch the app in the simulator
  2. Open Activity Monitor
  3. Find the name of your app in the CPU tab
  4. Double-click it and open the "Open Files and Ports"

enter image description here

Sergey Lost
  • 2,301
  • 2
  • 17
  • 22
  • 2
    `NSString *uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];` gives you the device identifier – oabarca Jul 20 '16 at 01:05
  • @oabarca the identifier your get has nothing to do with the simulator's deviceID or appFolder; I'm using Xcode 11.2.1 and iOS 13.2.2 – DawnSong Nov 21 '19 at 09:11
77

Found it:

~/Library/Application Support/iPhone Simulator/User/
Codebeef
  • 41,810
  • 20
  • 83
  • 116
77

Easiest way ever.

  1. Catch a Breakpoint somewhere.

  2. Enter po NSHomeDirectory() in console window

Result:

(lldb) po NSHomeDirectory() /Users/usernam/Library/Developer/CoreSimulator/Devices/4734F8C7-B90F-4566-8E89-5060505E387F/data/Containers/Data/Application/395818BB-6D0F-499F-AAFE-068A783D9753

Community
  • 1
  • 1
Lal Krishna
  • 12,476
  • 4
  • 53
  • 65
74

iOS 8 ~/Library/Developer/CoreSimulator/Devices/[Device ID]/data/Applications/[appGUID]/Documents/

Wagh
  • 2,598
  • 1
  • 23
  • 28
65

On Lion the Users/[username]/Library is hidden.

To simply view in Finder, click the 'Go' menu at the top of the screen and hold down the 'alt' key to show 'Library'.

Click on 'Library' and you can see your previously hidden library folder.

Previously advised:

Use

chflags nohidden /users/[username]/library

in a terminal to display the folder.

tipycalFlow
  • 7,514
  • 4
  • 31
  • 45
Rafael Moreira
  • 1,749
  • 1
  • 19
  • 20
  • 1
    then after that you can find it at: ~/Library/Application Support/iPhone Simulator/[OS version]/Applications/[appGUID]/ – Rafael Moreira Oct 31 '11 at 02:00
  • That's an interesting suggestion for normal users, but it seems to me that iOS / OS X developers need to access library on a pretty regular basis and so wouldn't want it hidden ever again. (Then again, I guess a lot of developers use Terminal instead of Finder?) – ArtOfWarfare Apr 11 '13 at 22:33
44

If the Simulator is running you can get the path to any app's container:

xcrun simctl get_app_container booted <app bundle identifier>

Example output:

$ xcrun simctl get_app_container booted com.example.app
/Users/jappleseed/Library/Developer/CoreSimulator/Devices/7FB6CB8F-63CB-4F27-BDAB-884814DA6FE0/data/Containers/Bundle/Application/466AE987-76BC-47CF-A207-266E65E7DE0A/example.app

"booted" can be substituted to most simctl commands anywhere a device UDID is expected.

You can see the list of devices with xcrun simctl list and get help on specific commands with xcrun simctl help.

Update: By popular request in Xcode 8.3 you can now specify the kind of container you want by appending "app", "data", "groups", or an app group identifier.

To get the data container:

$ xcrun simctl get_app_container booted com.example.app data
russbishop
  • 14,900
  • 6
  • 54
  • 71
35

With Xcode 5 you may use the code below:

#import <Foundation/NSFileManager.h>

and:

NSString *homeDir = NSHomeDirectory();
NSLog(@"%@",homeDir);

The result may look look like:

"/Users/<your user name>/Library/Application Support/iPhone Simulator/7.1/Applications/hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh"

Where hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh is some hex string identifying your iOS app.

BoltClock
  • 630,065
  • 150
  • 1,295
  • 1,284
Pisca46
  • 864
  • 8
  • 11
30

Looks like Xcode 6.0 has moved this location once again, at least for iOS 8 simulators.

~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Containers/Data/Application/[AppID]

awolf
  • 1,632
  • 20
  • 27
  • 4
    in ~/Library/Developer/CoreSimulator/Devices/[DeviceID]/ there is also a .plist file named "device.plist" if you look inside you can find out device name like iphone-6 or iphone-5s. deviceID is very confusing so i think you should look inside the .plist file. – EFE Oct 21 '14 at 08:23
  • 1
    How to get the AppID? – Display Name Apr 27 '15 at 11:09
  • 1
    I cheated to find the app id, by using 'ls -l' and figuring out which app's files had been created the most recently. Might work for others too. – Maya Webster Jun 09 '15 at 22:58
  • 1
    Or in finder sort by "date created" to get the App on top of the list. – Ammar Mujeeb Apr 14 '17 at 06:28
30

One of the most easy ways to find where the app is within the simulator. User "NSTemporaryDirectory()"

Steps-

  1. Apply breakpoint anywhere within the app and run the app.
  2. When the app stops at the breakpoint, type following command in Xcode console.

    po NSTemporaryDirectory()

See the below image for a proper insightenter image description here

Now you have the exact path upto temporary folder. You can go back and see all app related folders.

Hope this also helps. Happy Coding :)

Shubhendu
  • 1,051
  • 8
  • 13
10

Where Xcode stores simulators in 2019+ Catalina, Xcode 11.0

Runtimes

$ open ~/Library/Developer/CoreSimulator/Profiles/Runtimes

For example: iOS 13.0, watchOS 6.0 These take the most space, by far. Each one can be up to ~5GB

Devices

$ open ~/Library/Developer/CoreSimulator/Devices

For example: iPhone Xr, iPhone 11 Pro Max. These are typically <15 mb each.

Explanation

Simulators are split between runtimes and devices. If you run $ xcrun simctl list you can see an overview, but if you want to find the physical location of these simulators, look in these directories I've shown.

It's totally safe to delete runtimes you don't support. You can reinstall these later if you want.

codejockie
  • 5,692
  • 3
  • 29
  • 36
joshuakcockrell
  • 3,609
  • 2
  • 26
  • 36
9

Simply do this:

NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSLog(@"%@", docDirPath);

And you will get somethink like this:

/Users/admin/Library/Developer/CoreSimulator/Devices/58B5B431-D2BB-46F1-AFF3-DFC789D189E8/data/Containers/Data/Application/6F3B985F-351E-468F-9CFD-BCBE217A25FB/Documents

Go there and you will see the document folder of your app regardless of the version of XCode. (Use "Go to Folder..." command in Finder and specify a path "~/library").

Swift version for string path:

let docDirPath =
NSSearchPathForDirectoriesInDomains(.documentDirectory,
                                    .userDomainMask, true).first
print(docDirPath)

and folder URL:

let docDirUrl =
    FileManager.default.urls(for: .documentDirectory,
                             in: .userDomainMask).first
print(docDirUrl)
LembergSun
  • 572
  • 6
  • 11
  • Was about to post almost the same answer. This method has the advantage to always give the correct path, on any version of iOS simulator. By the way, you can also copy the value of the url variable in the debugger, if you don't want to log it ;) – Moose Nov 02 '16 at 15:13
7

In iOS 5 :

/Users/[User Name]/Library/Application Support/iPhone Simulator/5.0/Applications/[AppGUID]/

Karthi
  • 111
  • 1
  • 4
6

For Xcode 4.6 it gets stored in the following path...

/Users/[currentuser]/Library/Application Support/iPhone Simulator/6.1/Applications/

To know it programmatically use the following code

  NSLog(@"path:%@",[[NSBundle mainBundle]bundlePath]);
Durai Amuthan.H
  • 28,889
  • 6
  • 148
  • 223
4

For iOS 8

To locate the Documents folder, you can write a file in the Documents folder:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent:@"Words.txt"];
NSString *content = @"Apple";
[content writeToFile:fileName atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil];

say, in didFinishLaunchingWithOptions.

Then you can open a Terminal and find the folder:

$ find ~/Library -name Words.txt
ohho
  • 47,708
  • 70
  • 236
  • 372
2

For react-native users who don't use Xcode often, you can just use find. Open a terminal and search by with the database name.

$ find ~/Library/Developer -name 'myname.db'

If you don't know the exact name you can use wildcards:

$ find ~/Library/Developer -name 'myname.*'

sheepdog
  • 617
  • 5
  • 16
2

For macOS Catalina, I found my db in:

~/Library/Developer/CoreSimulator/Devices/{deviceId}/data/Containers/Data/Application/{applicationId}/Documents/my.db

To get the applicationId, I just sorted the folders by date modified, though I'm sure there's a better way to do that.

stevenspiel
  • 4,740
  • 10
  • 51
  • 82
2

if anyone is still experiencing this problem in lion, there is a great article with 19 different tips to view your ~/Library dir. find the article by Dan Frakes here http://www.macworld.com/article/161156/2011/07/view_library_folder_in_lion.html

Remember the directory to the simulator is given below

~/Library/Application Support/iPhone Simulator/User/

Edwin
  • 3,812
  • 2
  • 19
  • 16
1

I have no affiliation with this program, but if you are looking to open any of this in the finder SimPholders makes it incredibly easy.

Jason
  • 1,993
  • 2
  • 17
  • 26
0

You can try using the below code

NSString *fileName = @"Demo.pdf";
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
    NSLog(@"File path%@",pdfFileName);
Raees Madathil
  • 207
  • 1
  • 3
  • 11
0

To Open the dictories where you App are that you build in xCode on the simulators, do the following:

  1. open a Finder windor ( smiley face icon )
  2. then click GO -> Go to Folder
  3. type: ~/Library/Application Support/iPhone Simulator
  4. The Directories are the iOS version of the different Simulators
  5. The Sub Directories are the Apps install on the simulator
  6. The Documents folder is where the user generated content which gets backup up onto iCloud
Mike Zriel
  • 1,141
  • 1
  • 12
  • 26