Codebeef
Codebeef

Reputation: 44036

Where does the iPhone Simulator store its data?

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?

Upvotes: 295

Views: 224169

Answers (22)

Ahmad Sami
Ahmad Sami

Reputation: 327

The easiest way I found is to generate a file with a special name and search for it in /Users/[USERNAME]/Library/Developer/CoreSimulator

Ex. Create file named report_2023-12-23_23-49-15 >> Go to the path above in Finder and search for the file name >> right click on the file and click Get Info it will give you the path for your simulator

enter image description here

Upvotes: 2

joshuakcockrell
joshuakcockrell

Reputation: 6153

Where Xcode stores simulators & runtimes

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.

Upvotes: 13

Lal Krishna
Lal Krishna

Reputation: 16200

Easiest way ever.

  1. Catch a Breakpoint somewhere. (or Pause program execution (tap on pause in debug area) as Najdan Tomić mentioned on the comments)

  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

Upvotes: 158

dsmudger
dsmudger

Reputation: 3671

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]/

Upvotes: 330

stevenspiel
stevenspiel

Reputation: 6009

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.

Upvotes: 3

sheepdog
sheepdog

Reputation: 625

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.*'

Upvotes: 2

LembergSun
LembergSun

Reputation: 661

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)

Upvotes: 10

Jason
Jason

Reputation: 2353

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.

Upvotes: 2

russbishop
russbishop

Reputation: 17249

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

Upvotes: 54

Shubhendu
Shubhendu

Reputation: 1091

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 :)

Upvotes: 32

Sergey Lost
Sergey Lost

Reputation: 2551

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

Upvotes: 127

awolf
awolf

Reputation: 1972

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]

Upvotes: 30

Mike Zriel
Mike Zriel

Reputation: 1865

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

Upvotes: 0

Wagh
Wagh

Reputation: 2688

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

Upvotes: 75

ohho
ohho

Reputation: 51951

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

Upvotes: 4

Pisca46
Pisca46

Reputation: 914

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.

Upvotes: 37

Durai Amuthan.H
Durai Amuthan.H

Reputation: 32320

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]);

Upvotes: 6

Raees Madathil
Raees Madathil

Reputation: 291

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);

Upvotes: 0

Rafael Moreira
Rafael Moreira

Reputation: 1769

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.

Upvotes: 65

Karthi
Karthi

Reputation: 111

In iOS 5 :

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

Upvotes: 7

Edwin
Edwin

Reputation: 3802

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/

Upvotes: 2

Codebeef
Codebeef

Reputation: 44036

Found it:

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

Upvotes: 75

Related Questions