How do I get video into the iPhone simulator camera roll in iOS 4.2?
Asked Answered
L

9

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.

Luciferin answered 6/1, 2011 at 19:28 Comment(0)
G
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.

Glarum answered 24/9, 2014 at 19:21 Comment(2)
Original attempt failed. Removing "Download" & "PhotoData" completed it. Nice find.Flocculus
You can identify the simulator UDID via the Xcode interface too: #6952779.Villosity
F
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!

Fayfayal answered 20/8, 2013 at 15:31 Comment(6)
Such a feasible way! Thnaks!Crispate
Does not worked for me on iOS7 simulators started from XCode 6.0.1. On iOS8 simulator it is working fine.Teriann
in version 10.0 even more simple! just open Photos app, drag and drop, done!Besnard
Perfect :) ThanksTransudation
Super doper! Easy peasy! Still working for Xcode 11Conwell
Nice! Best answer!Encumbrance
A
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.

Almallah answered 2/5, 2019 at 18:57 Comment(0)
G
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.

Glarum answered 24/9, 2014 at 19:21 Comment(2)
Original attempt failed. Removing "Download" & "PhotoData" completed it. Nice find.Flocculus
You can identify the simulator UDID via the Xcode interface too: #6952779.Villosity
P
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.

Powered answered 9/5, 2015 at 3:6 Comment(0)
D
2

Have you seen the solution by Shizam, here:

iphone - How do I add videos to iPad simulator?

It requires code, however.

Dickson answered 7/1, 2011 at 0:6 Comment(2)
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.Luciferin
I couldn't get the "old" method to work, but the code method worked fine. Looks like Apple has locked it down :(. Idiots.Mopes
L
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'
Leonoreleonsis answered 1/1, 2015 at 21:20 Comment(0)
O
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

Ossie answered 6/1, 2011 at 23:56 Comment(1)
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.Luciferin
M
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

Mopes answered 18/2, 2011 at 17:28 Comment(3)
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.Daleth
Worked in iOS 4. Apple keeps changing folder names with each version of iOS. File a bug report with Apple.Mopes
This creates a black image in iOS6 instead of a videoCongeries
E
0

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

Eternity answered 25/10, 2018 at 2:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.