Solution: How to get files in Files app in iOS simulator

When using the iOS simulator, I encountered an issue when trying to share a file saved in the Files app. I wanted to copy the file to my…

Solution: How to get files in Files app in iOS simulator

When using the iOS simulator, I encountered an issue when trying to share a file saved in the Files app. I wanted to copy the file to my computer, but I was unsure of how to accomplish this as the share button only displayed options for Remind and More. Even when I clicked the More button, only the Reminder option was available.

Initially, I expected to see an AirDrop option, similar to when sharing a file to the simulator from the computer’s disk. Unfortunately, I couldn’t find the AirDrop option in this case. Another approach I considered was dragging the file out of the simulator and onto my computer, but it proved unsuccessful as the file couldn’t be dragged outside the simulator’s environment.

In an attempt to locate the file, I navigated to the app’s document directory, but couldn’t find the desired files there. Feeling stuck, I decided to seek assistance from ChatGPT. It suggested sharing the file via email or messages, but those options were nowhere to be found. As a result, I chose the Reminder option out of frustration. Surprisingly, when I shared the file with the Reminder option, instead of attaching the file, it displayed the local file location.

To my relief, I discovered that the files were actually located on my local machine. The file’s location is as follows:

file:///Users/<UserName>/Library/Developer/CoreSimulator/Devices/B1BE4D1B-8152-4D46-8F49-AA3A244F6CFB/data/Containers/Shared/AppGroup/CB7212B7-2E01-40A1-A0B8-FACB3BF49F3B/File%20Provider%20Storage/<file_name>

We can also get the path through the following command:

xcrun simctl listapps booted

For the files app, the output is like below:

"com.apple.DocumentsApp" =     { 
        ApplicationType = System; 
        Bundle = "file:///Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/Files.app/"; 
        CFBundleDisplayName = Files; 
        CFBundleExecutable = Files; 
        CFBundleIdentifier = "com.apple.DocumentsApp"; 
        CFBundleName = Files; 
        CFBundleVersion = "280.5.15"; 
        DataContainer = "file:///Users/Stephen/Library/Developer/CoreSimulator/Devices/B1BE4D1B-8152-4D46-8F49-AA3A244F6CFB/data/Containers/Data/Application/EEDA2436-25D7-4F65-B100-671FE2483855/"; 
        GroupContainers =         { 
            "group.com.apple.DocumentManager" = "file:///Users/Stephen/Library/Developer/CoreSimulator/Devices/B1BE4D1B-8152-4D46-8F49-AA3A244F6CFB/data/Containers/Shared/AppGroup/D12E8BA4-3787-4A3F-AC67-71A989579285/"; 
            "group.com.apple.FileProvider.LocalStorage" = "file:///Users/Stephen/Library/Developer/CoreSimulator/Devices/B1BE4D1B-8152-4D46-8F49-AA3A244F6CFB/data/Containers/Shared/AppGroup/CB7212B7-2E01-40A1-A0B8-FACB3BF49F3B/"; 
        }; 
        Path = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/Files.app"; 
        SBAppTags =         ( 
        ); 
    };

The directory is saved with key: group.com.apple.FileProvider.LocalStorage under GroupContainers.