22

I've tried the solution described here and here, namely copying a QuickTime movie to ~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/VID_0001.m4v, but this doesn't seem to do anything, and I'm guessing something's changed since iOS 3.2 to make it not work.

Note that I'd very much prefer a solution that doesn't involve adding code to my app, unless that really is the only way to do it.

ETA: I know that it's possible to include video files as a resource; what I want is to add video files to the camera roll -- as can be done with photos by (for instance) saving images from Safari -- so I can test functionality that involves picking media files.

Updated again: If somebody can definitively tell me it's not possible, with references, that would be helpful too.

Community
  • 1
  • 1
David Moles
  • 48,006
  • 27
  • 136
  • 235

9 Answers9

55

I found a way that seems to work in most versions of the simulator (confirmed for 6.1):

  1. Start up the simulator and navigate to the photos app from the home screen.
  2. Drag and drop an .m4v file from your file system onto the simulator window. The video will now be playing in safari.
  3. Click "done" in the upper left hand corner.
  4. Click on the "share" button and select "save to camera roll"

You're done!

Pwnosaurus
  • 2,058
  • 1
  • 19
  • 21
11

In Xcode 10+, you can just drag-and-drop the video(s) into the simulator. If the Photos app is not open already, it will open and show the videos right there alongside the built-in sample photos.

Jonathan Cabrera
  • 1,656
  • 1
  • 19
  • 20
10

For XC6 simulators, you can search for the simulator directory with this command-line command:

For example, if you want to find the directory with the "5s" device:

grep -r -e "5s" --include="device.plist" ~/Library/Developer/CoreSimulator/Devices

Once you have the folder, you can navigate to:

<your-sim>/data/Media/DCIM/100APPLE

and copy your files in there. When you launch the simulator, you should open the Photos app and it should "restore" the metadata for the media. If that's not the case, you can also remove the "Downloads" and "PhotoData" folders and relaunch the simulator.

Dan Waylonis
  • 802
  • 8
  • 11
  • Original attempt failed. Removing "Download" & "PhotoData" completed it. Nice find. – Dustin Pfannenstiel Mar 08 '17 at 20:04
  • You can identify the simulator UDID via the Xcode interface too: https://stackoverflow.com/questions/6952279/how-to-check-device-id-of-iphone-simulator. – Paul Oct 29 '20 at 18:55
6

This is what I had to do for Xcode 6.3.1 / iOS 8:

  • open Safari
  • enter the filepath to the m4v on your Mac's HD using the file:// protocol, e.g. file:///Users/brentd/Desktop/video.m4v.
  • Click Done
  • Click the share button
  • Choose "Save Video"

The video will now be in your camera roll.

Brent Dillingham
  • 1,019
  • 1
  • 13
  • 22
2

this does not work ( does not open safari ) if you have an app installed on the simulator which has document .ext handler , it open's that app instead of safari, so just simply

  • open safari on the simulator
  • drag a video file from your desktop and drop it on the simulator's safari
  • Click 'Done'
  • Click 'Share'
  • Select 'Save To Camera Roll'
Rhm Akbari
  • 362
  • 3
  • 12
2

Have you seen the solution by Shizam, here:

iphone - How do I add videos to iPad simulator?

It requires code, however.

Community
  • 1
  • 1
TomSwift
  • 39,369
  • 12
  • 121
  • 149
  • Yeah, I saw that, and I expect I can get it to work, but as I said I'd rather not have to do it in code. – David Moles Jan 07 '11 at 17:38
  • I couldn't get the "old" method to work, but the code method worked fine. Looks like Apple has locked it down :(. Idiots. – Adam Feb 18 '11 at 17:26
1

If you stick your MP4 file into the "Resources" group/folder in xcode the simulator will have access to it just like other local resources.

Below is an example on devx that illustrates playing a movie file from the resources group.

devx Example

Citrrus-Jason
  • 87
  • 1
  • 8
  • I'm aware of that -- what I'm looking for is a (non-programmatic) way to add video to the camera roll, as is possible with photos. – David Moles Jan 07 '11 at 17:38
1

I used the code solution in the end, but looking at the simulator folders afterwards, it's using a different naming strategy for the videos.

Maybe it will work if you save the file as:

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

Adam
  • 32,900
  • 16
  • 126
  • 153
  • Tried this and it didn't work. I would dearly love to know the correct place to put a video so that it shows up in Camera Roll. – mpemburn Apr 20 '12 at 15:39
  • Worked in iOS 4. Apple keeps changing folder names with each version of iOS. File a bug report with Apple. – Adam Apr 22 '12 at 12:07
  • This creates a black image in iOS6 instead of a video – Nikita P Feb 22 '13 at 05:08
0

Sign in to your iCloud account from the simulator. Sync your phone photos and videos with iCloud. They will simply appear.

Kamrul
  • 324
  • 2
  • 8