xcrun simctl list devices or print the path at runtime using FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first.Why this happens
Apple restructured the Simulator filesystem starting with iOS 8 (Xcode 6). The old ~/Library/Application Support/iPhone Simulator/ layout was replaced by CoreSimulator, which isolates each device runtime and app container behind UUIDs. This change improves parallel testing and device management but makes the Documents folder harder to locate manually.
Each simulator device gets a unique identifier (UDID). Inside that device, every installed app receives its own container UUID. The Documents folder you want is nested three levels deep: Device UDID β App Container UUID β Documents. Because both UUIDs change per device and per app install, there is no single static path you can bookmark.
How to fix it
1. Print the path at runtime (fastest during development)
Add a temporary line in your app launch code to log the exact Documents URL for the running simulator.
import Foundation
func logDocumentsDirectory() {
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
if let docs = urls.first {
print("π Documents directory: \(docs.path)")
}
}
// Call once, e.g. in AppDelegate or @main entry point
logDocumentsDirectory()
Run the app in the target simulator. Copy the printed path, open Finder, press ββ§G, paste, and press Return. Remove the logging line before shipping.
2. Use simctl to resolve the current booted device
When you need the path from a script or terminal without running the app:
# List all devices and their UDIDs
xcrun simctl list devices
# If a device is booted, get its UDID
BOOTED_UDID=$(xcrun simctl list devices | grep -E 'Booted' | head -1 | sed -E 's/.*\(([^)]+)\).*/\1/')
echo "Booted device UDID: $BOOTED_UDID"
The device root is ~/Library/Developer/CoreSimulator/Devices/$BOOTED_UDID/data. Your app container lives under Containers/Data/Application/. List them:
ls -la ~/Library/Developer/CoreSimulator/Devices/$BOOTED_UDID/data/Containers/Data/Application/
Pick the folder with the most recent modification time (your app), then open its Documents subfolder.
3. Jump directly from Xcode’s Devices window
- Open Window β Devices and Simulators (ββ§2).
- Select the simulator on the left.
- Under Installed Apps, right-click your app β Show Container.
- Finder opens at the app container root. Open
Data β Documents.
This method requires no terminal commands and works even if the app isn’t currently running.
4. Create a reusable Finder shortcut (one-time setup)
Make a New Finder Window target that always opens the CoreSimulator root:
- In Finder, press ββ§G and paste
~/Library/Developer/CoreSimulator/Devices. - Drag the
Devicesfolder into the Finder sidebar (Favorites). - Rename it to Sim Devices for clarity.
Now you can click the sidebar item, navigate into the latest device folder (sort by Date Modified), then data/Containers/Data/Application/ to find your app.
5. Swift helper for debug builds only
Wrap the path lookup in a #if DEBUG block so it never ships:
#if DEBUG
func debugDocumentsURL() -> URL? {
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
}
// Example: write a test file to verify sandbox access
if let docs = debugDocumentsURL() {
let testFile = docs.appendingPathComponent("debug-marker.txt")
try? "Simulator sandbox OK".write(to: testFile, atomically: true, encoding: .utf8)
print("Wrote test file to \(testFile.path)")
}
#endif
How to prevent it
- Always resolve the path at runtime with
FileManagerinstead of hard-coding a UUID path. - Use the Devices window for one-off inspections; it stays in sync across Xcode updates.
- Add a debug-only helper to your project template so new apps get instant Documents access.
- Avoid symlinking the Documents folder into your project β sandbox paths change on device reset.
FAQ
Why does the Documents folder appear empty in Finder but my app reads files fine?
Finder may not refresh the sandbox view immediately. Press βR in Finder or reopen the folder. Also verify you opened the correct app container UUID β each reinstall generates a new one.
Can I share a Documents folder between two simulator apps?
No. Each app has its own container. Use App Groups (com.company.sharedgroup) and FileManager.default.containerURL(forSecurityApplicationGroupIdentifier:) to share a directory across apps on the same simulator.
Does this path change on physical devices?
Yes. On a real iPhone the path is /var/mobile/Containers/Data/Application/<UUID>/Documents. The FileManager API returns the correct path on both simulator and device, so always use the API instead of hard-coded strings.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.