Is there any way to see the file system on the iOS simulator?
Asked Answered
N

12

214

Is there any way to browse the file system of a currently running or just killed iOS simulator? I'd settle for being able to see a specific app's files if there's a way to do that.

Note that I don't want to do this programatically. I want to see/open the files in the Finder.

Nunciature answered 25/6, 2011 at 21:22 Comment(0)
N
273

UPDATE: Since iOS 8:

~/Library/Developer/CoreSimulator/Devices

The location used to be:

~/Library/Application Support/iPhone Simulator

It had directories for all models of simulators (4.0, 4.1, 5.0, etc) you have ever run, go to the one you are running from in Xcode.

Once in a folder, go to Applications, choose the Finder option that shows date for files, and sort by date. Your application will be the most recent since it just changed the directory...

Inside the directory is everything related to your application. You can even drop files in there between runs, to revert back to a stored database in a known state for example...

I go there often enough I keep the iPhone Simulator directory in my Finder sidebar.

Note that with iOS8, the simulator folders are in a totally different directory - really split across a few directories, with folder names for application specific files that change each time you run your app.

Nutritive answered 25/6, 2011 at 21:32 Comment(6)
To see the ~/Library folder in Lion you'll need to run this command in Terminal: chflags nohidden ~/Library/Sauerkraut
You can also press the option key while viewing Finder's Go menuClueless
I use ⌘⇧G from Finder. It's faster than opening Terminal to cd.Radarscope
Hold down 'option' and hit 'Go' in the menubar in finderMendoza
Finding a specific app's file is almost impossible between the random hashes, use this command to actually get to the app's files: xcrun simctl get_app_container booted my.app.id dataEvaporation
Application store of simulator, for those wondering, is usually in ~/simulatorId/Data/Containers/applicationId/ (replace ID with the UUID they use, and find the most recent files)Schuman
S
88

iOS 8

Devices

~/Library/Developer/CoreSimulator/Devices

Applications

~/Library/Developer/CoreSimulator/Devices/{{Device Code}}/data/Containers/Bundle/
Simmon answered 18/7, 2014 at 6:8 Comment(4)
To determine your current {{Device Code}}}, an easy way is to open the desired simulator in Xcode, and then in Finder sort the ~/Library/Developer/CoreSimulator/Devices/ directory by Date Modified. Most recent is the one you want.Enenstein
For the application data: ~/Library/Developer/CoreSimulator/Devices/{{Device Code}}/data/Containers/Data/Application/{{Application Id}}Racialism
Actually, you can see the {{Device Code}} in Hardware > Device > Manage Devices...Fabio
Thnx, this answer is still relevant in 2021.Soberminded
C
44

based on zsero answer

Details

macOS 10.13.1

Solution 1

Run the following line in the terminal

Template

open `xcrun simctl get_app_container booted BUNDLEID_OF_YOUR_APP data` -a Finder

Full Sample

open `xcrun simctl get_app_container booted com.Test data` -a Finder

BUNDLEID_OF_YOUR_APP ???

BUNDLEID_OF_YOUR_APP = "Bundle Identifier"

enter image description here

Features of the solution 1

  • open file to get app simulator directory

Solution 2

Create a bash scrip with a name of your app and code:

script_file_name = `basename "$0"`
open `xcrun simctl get_app_container booted $script_file_name data`

enter image description here

Features of the solution 2

  • open file to get app simulator directory
  • rename file to get another app simulator directory

Result

enter image description here

Commensurable answered 15/12, 2017 at 16:12 Comment(1)
Seems you need to add " Finder" at the end of the "Full Sample" string.Manuelmanuela
P
43

Easy. Fast. Xcode 10+.

  1. Use print(NSHomeDirectory()) and copy the path.
  2. Open Finder app and press Shift+Cmd+G
  3. Paste the copied path and press GO

Alternative for 1. is to catch a breakpoint and do po NSHomeDirectory() in console.

Phagocyte answered 19/11, 2018 at 10:56 Comment(4)
Where do I run step 1?Tilden
@CarsonHolzheimer in your code, for example in viewDidLoad of your ViewController. maybe I should have written not "run" but something else. thanks!Phagocyte
You could also execute: po NSHomeDirectory() in lldb when stopped on a breakpointDionnadionne
Thank you. This is the first thing to work for me after an hour or so of trying various suggestions I've found.Fascinate
I
34

Open the program "Activity Monitor", search for your App (just the apps name, not the simulator), click "Informations" and open "Open files and ports". Copy the second entry (something like /Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/YourApp). This is the running app, while <...>/B97A9504-0FA5-4826-BB6D-A2335A676459/VSGradientView.app/ is the bundle, and <...>/B97A9504-0FA5-4826-BB6D-A2335A676459/* the sand-boxed folder.

If you pass this as open "/Users/me/Library/Application Support/iPhone Simulator/4.2/Applications/B97A9504-0FA5-4826-BB6D-A2335A676459/" to the terminal, the folder will open in Finder.

Sounds complicated but isn't.

Isochronism answered 25/6, 2011 at 22:12 Comment(3)
Good point! In particular, you don't need to go to .app to see a filesystem of your application.Loose
Great suggestion.. Really hope there is a script or little utility to help with this.. Each iOS device emulated as a completely different folder it seems.. The folder structure is all over the place in the new version.. :(Deviltry
excellent answer, specially when the route has change with the Xcode versionsBlayze
E
15

If you want to automate getting the location or use that folder in scripting, you can get the precise location from a running simulator with the following command:

xcrun simctl get_app_container booted my.app.id data
Evaporation answered 27/11, 2017 at 14:40 Comment(1)
very useful. To have it change directly into that directory I ran cd `xcrun simctl get_app_container booted my.app.id data` Dioptric
G
10

There is a nifty app that also supports the XCode 6 simulator.

https://github.com/somegeekintn/SimDirs

It is awesome, use it!

Graziano answered 13/11, 2014 at 16:35 Comment(0)
S
6

For Swift 4.2 and higher, print an easy to use path:

#if targetEnvironment(simulator)
    print("::::: SIMULATOR :::::")
    if let documentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.path {
        print("App Documents Directory:\n\(documentsPath)\n")
    }
#endif

... in a source code location such as:

func application(
    _ application: UIApplication, 
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    // ...
    return true
}

Use the resulting path with cd or open on the terminal command line. Or, paste the path in the shift-cmd-G "Go To Folder…" Finder prompt.

Related answer which includes older language versions: Document Directory Path of iOS 8 Beta Simulator

Sundstrom answered 11/10, 2019 at 18:19 Comment(0)
O
5

first, get simulator list with device ID from terminal

  1. instruments -s devices
  2. xcrun simctl list

Then go put device id below path. you will be get specific simulator file system ~/Library/Developer/CoreSimulator/Devices/{{deviceID}}

Ordway answered 21/3, 2020 at 20:55 Comment(0)
N
3

Old post, but I think it is worth mentioning SimPholders to find your Simulator files. It is a menu bar item that tracks your simulator apps and lets you go directly to their folders and content. It's super awesome.

(original answer here: https://mcmap.net/q/111625/-xcode-6-iphone-simulator-application-support-location)

Names answered 21/5, 2015 at 12:51 Comment(1)
Just confirmed that this app is still alive and kicking: simpholders.com . . . and it works great!Lay
C
2

Based on @zsero answer, I made a short bash script which directly opens the simulator folder of your application id. Very handy!

openappfolder.sh

#!/bin/bash

APPID=$1
if OUTPUT=`xcrun simctl get_app_container booted $APPID data` ; then
    open $OUTPUT
else
    echo "$APPID not found!"
fi 2>/dev/null

Then just

openappfolder.sh com.bundle.id

👍

Contuse answered 4/4, 2018 at 8:45 Comment(0)
S
0

On Xcode Version 8.2.1 (8C1002) I found the .app files installed on the simulator in this path: ~/Library/Developer/Xcode/DerivedData/[APPNAME]-[RANDOM HASH]/Build/Products/Debug-iphonesimulator

Solmization answered 2/2, 2017 at 4:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.