Reputation: 12481
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.
Upvotes: 217
Views: 125384
Reputation: 25294
based on zsero answer
macOS 10.13.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 = "Bundle Identifier"
Features of the solution 1
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`
Features of the solution 2
Upvotes: 46
Reputation: 9832
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
Upvotes: 6
Reputation: 25343
first, get simulator list with device ID from terminal
Then go put device id below path. you will be get specific simulator file system
~/Library/Developer/CoreSimulator/Devices/{{deviceID}}
Upvotes: 5
Reputation: 8147
print(NSHomeDirectory())
and copy the path.Shift+Cmd+G
Alternative for 1. is to catch a breakpoint and do po NSHomeDirectory()
in console.
Upvotes: 44
Reputation: 12203
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
👍
Upvotes: 2
Reputation: 13966
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
Upvotes: 16
Reputation: 1003
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
Upvotes: 0
Reputation: 3308
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://stackoverflow.com/a/26557165/377384)
Upvotes: 3
Reputation: 75058
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.
Upvotes: 276
Reputation: 928
There is a nifty app that also supports the XCode 6 simulator.
https://github.com/somegeekintn/SimDirs
It is awesome, use it!
Upvotes: 10
Reputation: 65785
~/Library/Developer/CoreSimulator/Devices
~/Library/Developer/CoreSimulator/Devices/{{Device Code}}/data/Containers/Bundle/
Upvotes: 89
Reputation: 52227
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.
Upvotes: 34