Your app might store some data or files in the Documents folder, and sometimes you might want to check if the data / files are stored correctly by inspecting them. How do we find the app folder containing the data?
You can also inspect the UserDefaults data by going to AppFolder/Library/Preferences/Your_app_bundle_id.plist .
Simulators
For simulator, the app folder is stored in your Mac. You can get the path of this folder by printing NSHomeDirectory()
print("app folder path is \(NSHomeDirectory())")
You can put this line in viewDidLoad function, and get the path in the Xcode console.
Copy the path, open Finder, then select "Go" -> "Go to Folder" (shortcut key Command + Shift + G), then paste in the path and press Enter.
If you don't want to modify your code, there's another way to locate the app folder.
Launch the simulator, then open Terminal app, type in the code below, replace the bundle ID with your app bundle ID :
open `xcrun simctl get_app_container booted BUNDLE_ID_OF_THE_APP data`
This will open the folder automatically.
Real device
For real device, you will need to download the whole app container to your Mac to inspect them.
Open Xcode, Select Window > Devices and Simulators
Select your device, then choose the app you want to inspect, then select "Download container" to download the app folder to your Mac.
The app container will be in .xcappdata format, you can inspect it by right clicking it -> "Show package contents"