How is possible to find quickly the document folder (in the mac) of an App when I'm using the simulator? When I need to explore the document folder during the simulation of the App now I use a variable of the App to find the document folder path and I read the path during the debug (using a variable) but I think is not the best solution.
Document folder iOS Simulator
Asked Answered
Set and hit a breakpoint in the app, and write the following in the Xcode Console (next to the Variables View):
po NSHomeDirectory()
Then in Finder hit Shift+CMD+G, paste the path returned above without the quotation marks and hit enter.
This throws a compiler error for me; adjusting it to
var homeDir = NSHomeDirecotry; print(homeDir)
(or examining the value of homeDir at a break point) works though. –
Mande @AlexHall This answer says to write this command in the console while paused at a break point. I misread it at first too and thought it meant to put this command in your code. –
Flossi
Open up Terminal.app and run:
xcrun simctl get_app_container booted [app identifier] data
You can even setup an alias to change to the directory, like:
alias cdmyapp='cd $(xcrun simctl get_app_container booted com.mycompany.myapp data)'
I like the alias idea! But this is just the bundle folder, not the Documents folder. –
Viewable
This is awesome. May I know where can I get the list of other such functions (e.g get_app_container)? I'm basically looking to fetch Documents Directory from command line. Any Help? –
Bender
This returns the .app bundle not the documents/data directory as the question asks –
Guideboard
Great answer, in the modern Xcode environment I think this is probably the fastest way. –
Attorneyatlaw
cd $(xcrun simctl get_app_container booted [app identifier] data) to get to the documents folder –
Windsor
open $(xcrun simctl get_app_container booted com.guidebook.guidebook data)/Documents
to open de documents folder. Notice data
and /Documents
. –
Lordly I have 2 solution
- Simpholders or free and open source alternative OpenSim
- A simple script that opens the finder window with the recently launched application on the iOS simulator
deviceId=$(xcrun simctl list devices | grep Booted | sed -n 's/^.([A-F0-9]{8}-([A-F0-9]{4}-){3}[A-F0-9]{12}).$/\1/p') applicationFolder=~/Library/Developer/CoreSimulator/Devices/$deviceId/data/Containers/Data/Application/ applicationFolder=$applicationFolder$(ls -Art $applicationFolder | tail -n 1) open $applicationFolder
This is the best I could do:
echo "Documents directory"
device_id=$(xcrun simctl list devices | grep Booted | sed -n 's/^.*\([A-F0-9]\{8\}-\([A-F0-9]\{4\}-\)\{3\}[A-F0-9]\{12\}\).*$/\1/p')
for folder in ~/Library/Developer/CoreSimulator/Devices/$device_id/data/Containers/Shared/AppGroup/*; do
documents_directory="$folder/File Provider Storage"
if [[ -a "$folder/File Provider Storage" ]]; then
echo $documents_directory
break
fi
done
© 2022 - 2024 — McMap. All rights reserved.
~/Library/Application\ Support/iPhoneSimulator
– Hokeypokey~/Library/Application Support/iPhone Simulator/7.1/Applications
when you're developing for 7.1. When you're developing for 8.0 then check for 8.0. When you change to a directory, you can check for other dirs available by pressing~/Library/App<tab>
. – Zasuwa