How can I add files to the iOS simulator?

Since none of the given solution worked for me on Simulator of iOS 13/Xcode 11, (trying to add a file, dragged from the Finder would just give an error), I found a workaround.

This takes a bit of setting up at first, but you get free access to the actual folder right from the Finder.

When I drag a file to the Simulator (providing no other App handles the file), the Files App would open, but when I save, I get "Invalid argument error".

The solution:

The folder named "On my phone" in the Simulator is called "File Provider Storage". The aim is to find it in the Finder.

The full path:

username/Library/Developer/CoreSimulator/Devices/device_hash_folder/data/Containers/Shared/AppGroup/hash_folder/File Provider Storage/

(Note:
Up until to current version (13.1), the Simulator does not work for picking files. You can see the files, but nothing happens on click.)

Here are the steps:

  1. Open the Files app on the Simulator and navigate to "On my phone" folder.
  2. (Still in the Simulator) Create a folder with a unique name.
    2a. You need to drag the screen down to reveal a '...' button. Pressing that will give you an option to create a new folder.

From here there are two ways

The short:

(In the Finder)
3a. Navigate to: username/Library/Developer/Core Simulator/Devices.
3b. Search for the folder you created. It should be in "File Provider Storage". That is the "On my phone" folder.

If the search does not find for any reason:

3a. Run an App and print (from Xcode) the path to documentDirectory (using FileManager).
3b. Open it in Finder and navigate back to "Containers folder".
3c. Navigate to Shared/AppGroup.
3d. You're looking for Shared/AppGroup/some_hashFolder/File Provider Storage/your_folder.
3e. Either look for modified date (folder created) of search for the folder name.


The easiest solution can be found here: https://apple.stackexchange.com/a/299565/140768

Short summary: You need an application which is able to handle/store "documents". As suggested in the linked post just create an empty "Document based" app and run it once.

enter image description here