Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add files to the iOS simulator?

Can someone tell me how can I add files to be used as test files for uploading from the simulator?

I dragged a PDF to the simulator and this is all I get. Can't really tap the Add button.

screenshot of the "add item" dialog

like image 559
Atif Imran Avatar asked Feb 20 '18 11:02

Atif Imran


People also ask

How do I access iOS simulator files?

# Open application folder in Finder First, copy the path to the app folder from Xcode console. Then open Finder, click on Go -> Go to Folder and paste the application directory path. You will now be able to browse all the files in your application folder.

Can you install apps on iOS simulator?

Install Apps on SimulatorsTo install an app on a connected simulator, follow these steps. Go to Apps > Install Application. Find and open the app you want to install from your Mac. The app appears in the list of installed apps on the right side of the iOS Gateway window.

Does iOS simulator Have App Store?

No. The iOS Simulator does not have an App Store.


1 Answers

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.

like image 54
bauerMusic Avatar answered Oct 03 '22 10:10

bauerMusic