12

I have used UIImagePickerController with UIImagePickerControllerSourceTypePhotoLibrary, but it says "No photos".

Where does the simulator get the images from? Where should I copy the images so that they are displayed in the simulator?

nhgrif
  • 61,578
  • 25
  • 134
  • 173
Want Query
  • 1,396
  • 1
  • 11
  • 12

5 Answers5

36

Now you can do this easily just by dragging and dropping the images in to Photos app in iPhone Simulator.

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
  • 3
    It sometimes take a few drags to get it work for me, if you can't get it to work for you just keep trying! – Carl Mar 12 '19 at 15:16
  • 2
    @Carl and I was wondering what wrong I am doing in dragging and dropping the images. Thanks :-) Great help. – Gaurav Grover Apr 13 '19 at 12:08
  • 1
    2021: If you drag from a safari picture on macbook, to photos, it will open up the safari browser to that same page on the simulator iphone. Then you have to long press in mobile safari until you see a menu open up to "Add to Photos" – John Pitts Aug 09 '21 at 22:09
8
  1. Run the simulator
  2. Run Safari on the Simulator
  3. Drag a picture onto Safari running on the Simulator, this opens the image.
  4. Click and hold on the image, or tap on the share icon in the bottom tool bar.
  5. You will get an alert asking if you want to store the image to your phone
Mats
  • 8,528
  • 1
  • 29
  • 35
Dirder
  • 363
  • 2
  • 3
  • 11
3

If someone gets an error similar to

One or more media items failed to import:

/Users/Username/Desktop/Screenshots/Screen Shot 2021-07-09 at 12.05.29.png: The operation couldn’t be completed. (Cocoa error -1.)

You can try to move the picture to the user's root folder. In my case /Users/Username/Screen Shot 2021-07-09 at 12.05.29.png, and I was able to drag and drop my image from Finder to the simulator.

John
  • 10,165
  • 5
  • 55
  • 71
1
  1. Open photo on simulator. The gallery will open.
  2. Drag the pic you want into the simulator gallery.
  3. That's it. The pic is now on the gallery.
Pang
  • 9,564
  • 146
  • 81
  • 122
  • I'm getting this error "The operation couldn’t be completed. (Cocoa error -1.)" – Soorya Jul 05 '21 at 05:26
  • @Soorya I had the same problem as you. I had to move the image to a different location on my Mac. Check out my answer https://stackoverflow.com/a/68340654/1471485. Maybe it works for you too. – John Jul 11 '21 at 23:52
0

You can drag files like images or video from your local mac machine to simulator once you open the photos or video list of the iphone.

But make sure you're uploading from Documents folder else it won't get uploaded if you drag files from other folders. enter image description here

jyotishman saikia
  • 2,079
  • 1
  • 15
  • 11