When you create a new iOS application on your Mac, the operating system installs it in a sandbox directory, which contains the application bundle directory and three additional directories, Documents, Library, and tmp. The application’s sandbox directory, often referred to as the home directory, can be accessed via code or Finder.
By the way, the OS used to create the application sandbox in this directory, on your Mac’s hard drive:
~/Library/Application/iPhone Simulator
Now, it is created in this directory:
~/Library/Developer/CoreSimulator
Accessing The App Documents Folder Via Code
Now, to retrieve and display the full path to an application’s Documents directory, you’d have to add this code snippet in a Swift file’s function; for example, the viewDidLoad() function.
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) as NSArray let documentsDir = paths.firstObject as String println("Path to the Documents directory\n\(documentsDir)")
Path to the Documents directory /Users/yourname/Library/Developer/CoreSimulator/Devices/E568C36B-48ED-416F-B374-451CB0F4ADA7/data/Containers/Data/Application/C9EB59E5-3290-4BD6-BF0E-081F43ADD4A8/Documents |
Accessing The App Documents Folder Via Finder
Now that you’ve gotten the full path to the application’s Documents folder. You can use Finder’s menu (Go > Goto Folder…) to navigate to that path. You’ll have to enter the path in Finder’s Goto Folder box like this:
~/Library/Developer/CoreSimulator/Devices/E568C36B-48ED-416F-B374-451CB0F4ADA7/data/Containers/Data/Application/C9EB59E5-3290-4BD6-BF0E-081F43ADD4A8/Documents
Once you click the Go button, Finder will take you straight to the application’s Documents folder.
That’s it. Now you know two ways to access your iOS application’s Documents folder.