Adding Images or Videos to iPhone Simulator

Adding images or videos to iPhone Simulator

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.

How do I add images to the iOS Simulator


  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'll get an alert asking if you want to store the image to your phone

How to add video to iphone simulator

okey, try this:

- (void) downloadVideo {
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sepwww.stanford.edu/sep/jon/trash/poolwaves.mov"]];

You can change the temp.mov to temp.m4v to save the vid in m4v.

NSString *tempPath = [NSString stringWithFormat:@"%@/temp.mov", NSTemporaryDirectory()];
[imageData writeToFile:tempPath atomically:NO];
UISaveVideoAtPathToSavedPhotosAlbum (tempPath, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}


- (void) video: (NSString *) videoPath
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo {
NSLog(@"Finished saving video with error: %@", error);
}

if you change the url to your moviefile, this should work really well...
the movies are saved in this directory: /Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM
but you are right, if i copy a file to it, it won't show up in the simulator

greets

iOS Simulator - Dragging images from Finder Not Adding to Photos in Xcode 10

Just hold the image to Photos icon and drop it, this will help you.

-Drag a photo

iOS Sample Image 21

Result:-
iOS Sample Image 22

How do I add photos to the iPhone Simulator for OSX?

Open the Window in mac where your images are stored.

Open your simulator another side.

Now drag your image from mac window to simulator,

simulator will open safari, and in a safari tab your image will be shown.

Tap & press down on image in simulator,

There will be message to "save image",

save image.

It will be added to your iPhone simulator.

Edit :

First just look at following image.

alt text

In iPhone simulator 4.0 ( iphone/iphone simulator ), itself it maintains a sqlite database for added images. So, if you want copy paste system - first make insert entries & then copy paste. That would be ridiculous way.

Ok. Let me explain simpler way of doing it.

  • open the finder in which you have bulk images that you want to add in simulator.
  • drag & drop first image into iphone simulator
  • on image - tap & hold for 1 second.
  • action sheet will appear - tap on save option
  • repeat same process for all images
  • this will do sqlite entries also.
  • now, open the /Users/YourUserName/Library/Application Support/iPhone Simulator/4.0
  • make a back up of Media directory. ( for example copy it & paste it on desktop )
  • when you reset your iphone simulator, all images will be gone
  • you need not to repeat all the process again, you have back up of it.
  • just copy & paste from back up to 4.0

alt text

Can not add images to iOS Simulator

Go to

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

…and add Dog.THM and Cat.JPG.

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

This might help you.

Adding image to iPhone simulator cause error (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.



Related Topics



Leave a reply



Submit