Adding images or videos to iPhone Simulator
Explain step by step of Airsource Ltd's answer for adding image to simulator:
- Drag it 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 ;)
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
The simplest way to get images, videos, etc onto the simulator is to drag and drop them from your computer onto the simulator. This will cause the Simulator to open the Photos app and start populating the library.
If you want a scriptable method, read on.
Note - while this is valid, and works, I think Koen's solution below is now a better one, since it does not require rebooting the simulator.
Identify your simulator by going to xCode->Devices, selecting your simulator, and checking the Identifier value. Or you can ensure the simulator is running and run the following to get the device ID xcrun simctl list | grep Booted
Go to
~/Library/Developer/CoreSimulator/Devices/[Simulator Identifier]/data/Media/DCIM/100APPLE
and add IMG_nnnn.THM and IMG_nnnn.JPG. You will then need to reset your simulator (Hardware->Reboot) to allow it to notice the new changes. It doesn't matter if they are not JPEGs - they can both be PNGs, but it appears that both of them must be present for it to work. You may need to create DCIM if it doesn't already exist, and in that case you should start nnnn from 0001. The JPG files are the fullsize version, while the THM files are the thumbnail, and are 75x75 pixels in size. I wrote a script to do this, but there's a better documented one over here(-link no longer work).
You can also add photos from safari in the simulator, by Tapping and Holding on the image. If you drag an image (or any other file, like a PDF) to the simulator, it will immediately open Safari and display the image, so this is quite an easy way of getting images to it.