[ios] Adding images or videos to iPhone Simulator

I am trying to use 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?

This question is related to ios iphone ios-simulator uiimagepickercontroller photo

The answer is


an even easier way, is : open safari on simulator > tap www.google.com search for random photos "nature" open each image, press on it and save it.


Just to tell you : KONG's solution also works on iOS 7 beta.

His solution was:

Drag the image to simulator, then Safari opens (or browse to the Image in the internet using Safari) Hold your click on the image When the pop-up appears, choose Save Image and enjoy ;)


For iOS 8.0,the answer is out of date.I found the media resource in the following path: ~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Media/DCIM/100APPLE


quit the simulator.

Run simulator from the dock by clicking on it.

Drag & drop the image into simulator which you want to add.

it will open image in safari .

tap and hold the image and click the save option.

then open gallery and you will see the image which u had saved recently.

an even easier way, is : open safari on simulator > tap www.google.com search for random photos "nature" open each image, press on it and save it.


For iOS 5.1 this is further changed to new path

~/Library/Application Support/iPhone Simulator/5.1/Media/DCIM/100APPLE


I just stumbled upon how to bulk upload images on the iOS Simulator. (I've only confirmed it on 6.1.)

  1. Backup the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media
    
  2. Copy all your images into the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
    
  3. Move or delete the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData
    
  4. Restart iOS Simulator

  5. Open the Photos app

The simulator will restore all the images from the 100APPLE folder!


Its simple. Just follow these steps :

  1. Drag and drop image onto Simulator
  2. Now image opens into Safari browser (file://.../ImageName). Tap-and-hold on the Image.
  3. This displays actionSheet with Save, Cancel option (Also copy in case of iOS 7 simulator).

    Screenshot for Actionsheet

  4. Save the image. The image gets added into Library.

    Photo Library


If you need to import more than just one or two photos then take a look at this article that I wrote. It describes an easy way to perform a bulk import of photos and works for iOS 4.x.


I just stumbled upon how to bulk upload images on the iOS Simulator. (I've only confirmed it on 6.1.)

  1. Backup the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media
    
  2. Copy all your images into the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
    
  3. Move or delete the folder:

    ~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData
    
  4. Restart iOS Simulator

  5. Open the Photos app

The simulator will restore all the images from the 100APPLE folder!


Since Xcode 6 you can use the command line tool xcrun simctl.

Usage is very simple; to add a photo to the currently running simulator you use the booted placeholder.

xcrun simctl addmedia booted ./MyFile.jpg

To add it to any other simulator, you use its device id, which can be found by running xcrun simctl list.

xcrun simctl addmedia E201E636-CE6C-11E5-AB30-625662870761 ./MyFile.jpg

With the drag and drop feature you will lose all the metadata of the photos.

I've created a project that make it really easy to import assets to the simulator: MBAssetsImporter.

It enables you to import both videos and photos while preserving all the original metadata of the files.


If you need to import more than just one or two photos then take a look at this article that I wrote. It describes an easy way to perform a bulk import of photos and works for iOS 4.x.


Adding an image to the Iphone Simulation running IOS 8.0 is even easier.

  • Drag your image to the simulator
  • IOS opens the Photo app and your image is now part of your collection.

No need to deal with Safari anymore


Its simple. Just follow these steps :

  1. Drag and drop image onto Simulator
  2. Now image opens into Safari browser (file://.../ImageName). Tap-and-hold on the Image.
  3. This displays actionSheet with Save, Cancel option (Also copy in case of iOS 7 simulator).

    Screenshot for Actionsheet

  4. Save the image. The image gets added into Library.

    Photo Library


For iOS 5.1 this is further changed to new path

~/Library/Application Support/iPhone Simulator/5.1/Media/DCIM/100APPLE


With the drag and drop feature you will lose all the metadata of the photos.

I've created a project that make it really easy to import assets to the simulator: MBAssetsImporter.

It enables you to import both videos and photos while preserving all the original metadata of the files.


I wrote a bash script to do this. Check the link[1]

#!/bin/bash

# Imports pictures into all iOS simulators.

path_to_pic="src/ios/pictures/"

mkdir -p /Users/$(whoami)/Library/Application\ Support/iPhone\ Simulator/{5.0,5.1,6.0,6.1}/Media/DCIM/100APPLE/
find ~/Library/Application\ Support/iPhone\ Simulator/ -type d -name '100APPLE' -exec cp /Users/$(whoami)/$path_to_pic/* {} \;

[1] : https://gist.github.com/firesofmay/5194901


As of iOS 8, you can just drag all your photos onto the simulator window and they'll save to camera roll automatically. You can do as many at a time as you want.


3 Simple Steps

  1. Drag & Drop image onto simulator
    - this will open a browser with your image
  2. Click & hold image
    - this will open options
  3. save image
    - this will copy image onto simulator

Watch YouTube Video ( add images to iphone simulator)


  1. Ensure the device is running.

  2. Execute the following in terminal:

open ~/Library/Developer/CoreSimulator/Devices/$(xcrun simctl list | grep Booted | grep -Eo '[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*-[a-zA-Z0-9]*')/data/Media/DCIM

Further regex ref @ https://regex101.com/r/tY951n/3


For iOS 7 I did the following:

copy photos to these two folders:

~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
~/Library/Application Support/iPhone Simulator/7.0/Media/DCIM/100APPLE

delete these 4 files only (to avoid duplicates on relaunch):

~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-wal
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-wal

If you can not drag and drop your files because you experience the error:

One or more media items failed to import: : The operation couldn’t be completed. (PHPhotosErrorDomain error -1.)

Move your files into the Documents folder and then drag them into the simulator. This will trigger the simulator to ask for permissions to access your files. Having them inside the Downloads folder, will not.


With iOS 11 and Xcode 9, just drag and drop photos to the Simulator. It will automatically import them in the Library app. Very easy!


1. CD to this path:

/Users/[macOS user]/Library/Developer/CoreSimulator/Devices/[Simulator Identifier]/data/Media/DCIM/100APPLE

[Simulator Identifier] or UDID can be found at : Hardware => device => manage devices.

eg. cd /Users/rnDeveloper/Library/Developer/CoreSimulator/Devices/7508171A-DC5D-47CF-9BE1-FF950326E3DB/data/Media/DCIM/100APPLE

2. Download photo by run this command:

curl -o pic_001.jpg "https://s-media-cache-ak0.pinimg.com/474x/49/25/7a/49257a4b3287b7841922ecdff855fd80.jpg"

3. Restart your simulator to see the new files.


In OS X Catalina with Xcode 11 you have to do this differently.

First you MUST start the simulator. If you want to copy, say a photo to MULTIPLE simulated devices. Start all of them up. Then Right Click on a SINGLE (Multiple images will fail. ONLY does a single file.).

Share -> Simulator

A 'share sheet will pop-up. You must choose an active simulator in the combo box and hit send.

It will send one to many but NOT many to many of selected photos.

I hope this helps folks. Drag and drop was supported in the last versions of Xcode and OS X but not with OS X Catalina and Xcode 11.

While this IS in the directions it currently IS NOT working.

What DID work for me was to first import my images into iPhoto on OS X and then DRAG/DROP them from my OS X iPhoto and drop into the simulator. It would appear the drag/drop for photos into the simulator is CURRENTLY only working from OS X iPhoto. :-(


None of the answers had the exact solution that I needed.

The steps I've found for myself working on iOS 5.0 and above simulator are as follows:

  1. Close the simulator if it is running xcode project.

  2. Run simulator from the dock by clicking on it.

  3. Drag & drop the image into simulator.

  4. Tap and hold the image (opened in safari) and select the save option.

You are done.


  1. Using your pc just Send the image via your email
  2. Open the IOS-Simulator then open the email and download the image

  3. just click and hold the mouse on the image, and from the options that will be displayedenter image description here

  4. Then, it will be automatically saved to your iOS-Simulator's photo gallery


For iOS 4.2 I had to go and create the 100APPLE folder and restart the simulator, then it worked.


This is MUCH easier with the new iOS Simulator that comes with Xcode 6+ (iOS Simulator 8.1 and above.) Now all you have to do is drag one or more photos onto the iOS Simulator window, and instead of opening Safari, the Photos app opens, and instantly adds all dragged-in photos to the device.


Explain step by step of Airsource Ltd's answer for adding image to simulator:

  1. Drag it to simulator, then Safari opens (or browse to the Image in the internet using Safari)
  2. Hold your click on the image
  3. When the pop-up appears, choose Save Image and enjoy ;)

Update: for iOS Simulator 4.2, do these steps twice to get it work. Thanks kevboh!

Update: This also works for iOS Simulator 6.1


None of the answers had the exact solution that I needed.

The steps I've found for myself working on iOS 5.0 and above simulator are as follows:

  1. Close the simulator if it is running xcode project.

  2. Run simulator from the dock by clicking on it.

  3. Drag & drop the image into simulator.

  4. Tap and hold the image (opened in safari) and select the save option.

You are done.


This is MUCH easier with the new iOS Simulator that comes with Xcode 6+ (iOS Simulator 8.1 and above.) Now all you have to do is drag one or more photos onto the iOS Simulator window, and instead of opening Safari, the Photos app opens, and instantly adds all dragged-in photos to the device.


Since Xcode 6 you can use the command line tool xcrun simctl.

Usage is very simple; to add a photo to the currently running simulator you use the booted placeholder.

xcrun simctl addmedia booted ./MyFile.jpg

To add it to any other simulator, you use its device id, which can be found by running xcrun simctl list.

xcrun simctl addmedia E201E636-CE6C-11E5-AB30-625662870761 ./MyFile.jpg

Just Drag and Drop image into iphone simulator. browser will open to show your image. press on image until you not receive options to save Image. then Save image. thats it :). you will see your image in to Photo app in your simulator....


1. CD to this path:

/Users/[macOS user]/Library/Developer/CoreSimulator/Devices/[Simulator Identifier]/data/Media/DCIM/100APPLE

[Simulator Identifier] or UDID can be found at : Hardware => device => manage devices.

eg. cd /Users/rnDeveloper/Library/Developer/CoreSimulator/Devices/7508171A-DC5D-47CF-9BE1-FF950326E3DB/data/Media/DCIM/100APPLE

2. Download photo by run this command:

curl -o pic_001.jpg "https://s-media-cache-ak0.pinimg.com/474x/49/25/7a/49257a4b3287b7841922ecdff855fd80.jpg"

3. Restart your simulator to see the new files.


With iOS 11 and Xcode 9, just drag and drop photos to the Simulator. It will automatically import them in the Library app. Very easy!


With iOS 8.0, we added the ability to just drag and drop images into the iOS Simulator. You can drag a bunch of images into the window, and they should be imported into the photo reel for that simulated device. You can also do this with the simctl command line tool. 'xcrun simctl addphoto '


Method 1 (Easiest Way): If you have your image on Mac

You can drag an image from the Finder on your Mac to Simulator, and it is saved to the Saved Photos album.

Method 2: If its on any URL

To save an image from a webpage to the Photos app

  1. Place the pointer on the image you want to save, and hold down the mouse button or trackpad.
  2. When the menu appears, click Save Image to save the image to the Photos app in an iOS simulator.
  3. The image is saved to the Saved Photos album in the Photos app.

Incase someone looking for Apple Documentation regarding Copying and Pasting in Simulator. Save Image from Safari


I just needed some random images for testing, so this is how I did it.

I have the simplest solution in the world. Just open Safari in the simulator, go to Google images (or your own web or Dropbox URL), view an image, hold down the mouse button for 2 seconds, and you'll see "Save Image" - it will save right into the Photos library. Rinse and repeat.


Explain step by step of Airsource Ltd's answer for adding image to simulator:

  1. Drag it to simulator, then Safari opens (or browse to the Image in the internet using Safari)
  2. Hold your click on the image
  3. When the pop-up appears, choose Save Image and enjoy ;)

Update: for iOS Simulator 4.2, do these steps twice to get it work. Thanks kevboh!

Update: This also works for iOS Simulator 6.1


In OS X Catalina with Xcode 11 you have to do this differently.

First you MUST start the simulator. If you want to copy, say a photo to MULTIPLE simulated devices. Start all of them up. Then Right Click on a SINGLE (Multiple images will fail. ONLY does a single file.).

Share -> Simulator

A 'share sheet will pop-up. You must choose an active simulator in the combo box and hit send.

It will send one to many but NOT many to many of selected photos.

I hope this helps folks. Drag and drop was supported in the last versions of Xcode and OS X but not with OS X Catalina and Xcode 11.

While this IS in the directions it currently IS NOT working.

What DID work for me was to first import my images into iPhoto on OS X and then DRAG/DROP them from my OS X iPhoto and drop into the simulator. It would appear the drag/drop for photos into the simulator is CURRENTLY only working from OS X iPhoto. :-(


If you can not drag and drop your files because you experience the error:

One or more media items failed to import: : The operation couldn’t be completed. (PHPhotosErrorDomain error -1.)

Move your files into the Documents folder and then drag them into the simulator. This will trigger the simulator to ask for permissions to access your files. Having them inside the Downloads folder, will not.


I wrote a bash script to do this. Check the link[1]

#!/bin/bash

# Imports pictures into all iOS simulators.

path_to_pic="src/ios/pictures/"

mkdir -p /Users/$(whoami)/Library/Application\ Support/iPhone\ Simulator/{5.0,5.1,6.0,6.1}/Media/DCIM/100APPLE/
find ~/Library/Application\ Support/iPhone\ Simulator/ -type d -name '100APPLE' -exec cp /Users/$(whoami)/$path_to_pic/* {} \;

[1] : https://gist.github.com/firesofmay/5194901


try this app I've made. download the code and run it in simulator https://github.com/cristianbica/CBSimulatorSeed


3 Simple Steps

  1. Drag & Drop image onto simulator
    - this will open a browser with your image
  2. Click & hold image
    - this will open options
  3. save image
    - this will copy image onto simulator

Watch YouTube Video ( add images to iphone simulator)


Method 1 (Easiest Way): If you have your image on Mac

You can drag an image from the Finder on your Mac to Simulator, and it is saved to the Saved Photos album.

Method 2: If its on any URL

To save an image from a webpage to the Photos app

  1. Place the pointer on the image you want to save, and hold down the mouse button or trackpad.
  2. When the menu appears, click Save Image to save the image to the Photos app in an iOS simulator.
  3. The image is saved to the Saved Photos album in the Photos app.

Incase someone looking for Apple Documentation regarding Copying and Pasting in Simulator. Save Image from Safari


The simplest solution is to simply sign into iCloud on the simulator then use that to transfer any files in the drive, including photos.


Just to tell you : KONG's solution also works on iOS 7 beta.

His solution was:

Drag the image to simulator, then Safari opens (or browse to the Image in the internet using Safari) Hold your click on the image When the pop-up appears, choose Save Image and enjoy ;)


quit the simulator.

Run simulator from the dock by clicking on it.

Drag & drop the image into simulator which you want to add.

it will open image in safari .

tap and hold the image and click the save option.

then open gallery and you will see the image which u had saved recently.

Adding an image to the Iphone Simulation running IOS 8.0 is even easier.

  • Drag your image to the simulator
  • IOS opens the Photo app and your image is now part of your collection.

No need to deal with Safari anymore


The simplest solution is to simply sign into iCloud on the simulator then use that to transfer any files in the drive, including photos.


I just needed some random images for testing, so this is how I did it.

I have the simplest solution in the world. Just open Safari in the simulator, go to Google images (or your own web or Dropbox URL), view an image, hold down the mouse button for 2 seconds, and you'll see "Save Image" - it will save right into the Photos library. Rinse and repeat.


Just drag images to the iPhone simulator.


For iOS 8, If there is no need to retain photo capture date and location, just drop photo files to the simulator.

To retain photo meta data, do the following:

  1. Copy photo files to: /Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/DCIM/100Apple
  2. Remove (or rename) folder: /Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/photoData
  3. Relaunch Simulator

Note: You need to replace {USER} with your user name and {UDID} with the UDID of the simulator. To find UDID for your simulator, from Terminal, run 'xcrun simctl list'.


With iOS 8.0, we added the ability to just drag and drop images into the iOS Simulator. You can drag a bunch of images into the window, and they should be imported into the photo reel for that simulated device. You can also do this with the simctl command line tool. 'xcrun simctl addphoto '


try this app I've made. download the code and run it in simulator https://github.com/cristianbica/CBSimulatorSeed


For iOS 8.0,the answer is out of date.I found the media resource in the following path: ~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Media/DCIM/100APPLE


Just drag images to the iPhone simulator.


  1. Using your pc just Send the image via your email
  2. Open the IOS-Simulator then open the email and download the image

  3. just click and hold the mouse on the image, and from the options that will be displayedenter image description here

  4. Then, it will be automatically saved to your iOS-Simulator's photo gallery


As of iOS 8, you can just drag all your photos onto the simulator window and they'll save to camera roll automatically. You can do as many at a time as you want.


For iOS 7 I did the following:

copy photos to these two folders:

~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE
~/Library/Application Support/iPhone Simulator/7.0/Media/DCIM/100APPLE

delete these 4 files only (to avoid duplicates on relaunch):

~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/6.1/Media/PhotoData/Photos.sqlite-wal
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-shm
~/Library/Application Support/iPhone Simulator/7.0/Media/PhotoData/Photos.sqlite-wal

For iOS 4.2 I had to go and create the 100APPLE folder and restart the simulator, then it worked.


Just Drag and Drop image into iphone simulator. browser will open to show your image. press on image until you not receive options to save Image. then Save image. thats it :). you will see your image in to Photo app in your simulator....


For iOS 8, If there is no need to retain photo capture date and location, just drop photo files to the simulator.

To retain photo meta data, do the following:

  1. Copy photo files to: /Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/DCIM/100Apple
  2. Remove (or rename) folder: /Users/{USER}/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/photoData
  3. Relaunch Simulator

Note: You need to replace {USER} with your user name and {UDID} with the UDID of the simulator. To find UDID for your simulator, from Terminal, run 'xcrun simctl list'.


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to iphone

Detect if the device is iPhone X Xcode 8 shows error that provisioning profile doesn't include signing certificate Access files in /var/mobile/Containers/Data/Application without jailbreaking iPhone Certificate has either expired or has been revoked Missing Compliance in Status when I add built for internal testing in Test Flight.How to solve? cordova run with ios error .. Error code 65 for command: xcodebuild with args: "Could not find Developer Disk Image" Reason: no suitable image found iPad Multitasking support requires these orientations How to insert new cell into UITableView in Swift

Examples related to ios-simulator

The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 flutter run: No connected devices Error Running React Native App From Terminal (iOS) How to uninstall downloaded Xcode simulator? Capture iOS Simulator video for App Preview iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development How to enable native resolution for apps on iPhone 6 and 6 Plus? How to access iOS simulator camera Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." Document directory path of Xcode Device Simulator

Examples related to uiimagepickercontroller

iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot How to allow user to pick the image with Swift? iOS UIImagePickerController result image orientation after upload Can I load a UIImage from a URL? Adding images or videos to iPhone Simulator Cropping an UIImage

Examples related to photo

open cv error: (-215) scn == 3 || scn == 4 in function cvtColor Link a photo with the cell in excel How can I link a photo in a Facebook album to a URL Adding images or videos to iPhone Simulator