开发者

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

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 resourc开发者_如何学Goe; 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.


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!


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.


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.


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.


Have you seen the solution by Shizam, here:

iphone - How do I add videos to iPad simulator?

It requires code, however.


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'


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜