OSX How To – View The NSDocumentDirectory Using Finder
This morning I was working on an iOS app that required saving various files to the device. I wanted to track these files while running the iPhone Simulator to make sure my code was handling the files as it was supposed to. To do this I could dig through the folder structure in Terminal or output a bunch of NSLogs with the data I wanted, but the easiest method would be to open Finder and watch the directory as changes were made. Since I know this will come up again in the future, I decided to make an AppleScript that will help me Quickly navigate to the iPhone Simulator path. Below are the steps I used to create the script.
Begin by opening the AppleScript Editor. Press Command + Spacebar to open Spotlight, type “AppleScript”, and then press Enter.
Next, enter the following code into the editor.
tell application "Finder" activate set x to (path to home folder as text) & "Library:Application Support:iPhone Simulator:5.1:Applications" as alias open x end tell
This script will open a Finder window to the Applications folder for the iPhone Simulator version 5.1. You can run the script now by clicking the Run button to see it work, but to make it so we can easily run it again later, we should save the file.
- Go to the menu and choose File > Save As.
- Enter a name for the script. I entered “Open Simulator Folder”.
- For where to save the files, I chose my Applications folder.
- Choose Application for the file format.
- And Finally Click the Save button.
Now, if you go to your Launchpad, you should be able to find the script and click on it to run it.
The Applications folder stores each of your apps in a folder with a long encrypted name, but you can usually determine which app you want by looking at the Modified date. Once you open the folder containing your app, you’ll see a file with the name of the app and a Documents folder. You can then double click on the Documents folder to view all the files your app has saved to the NSDocumentDirectory.