40

I have xcode 4.5.1 and want to add photos to the iphone 6.0 simulator but cant find it. I have a folder named iphone simulator but it just contains 4.3.1. It may be because some months ago I drag almost everything in the application support to my extern hard drive to save some memory. Now when I drag it back it contains the 4.3.1 which I used before. Do I have to download something on new or what should I do? Thanks in advance!

Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
wmichaelsen
  • 549
  • 1
  • 6
  • 14

8 Answers8

90
  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
Abizern
  • 146,289
  • 39
  • 203
  • 257
28

There is a slightly faster approach than what Abizern described

  1. Open the Simulator
  2. Drag an image directly onto it (no need to launch Safari.app)
  3. Safari willl launch
  4. Long-Press the image and save it to the Simulators Camera Roll

Update for iOS9: Locally stored images can be dragged directly onto the simulator and don't have to be saved explicitly.

enter image description here

Please note that your images are stored here (6.1 matches the Simulator version):

~/Library/Application Suppport/iPhone Simulator/6.1/Media/DCIM/100APPLE

Unfortunately you can't just add images to that folder as they will be ignored because they're not in the image database of the Simulator. However you can get all the stored images via the Finder.

Besi
  • 22,579
  • 24
  • 131
  • 223
  • In simulator version >= 7.0, this won't work at the first time. But will work after once you have done as what 'Abizern' said. :) – Krishna Raj Salim Dec 16 '13 at 18:09
  • @KrishnaRajSalim: Actually, with my iOS 9 Simulator this still works. Remote images can be saved like described and local images can just be dragged onto the simulator and will then show up in photos (without explicitly saving them) – Besi Jan 25 '16 at 11:18
15

With Xcode 6 is easier.

1.- Drag and drop an Image to the Simulator and the image will appear directly in the native Photos app.

Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
8

You can also now do this through the command line with smctl addmedia command.

$ xcrun simctl addmedia
Usage: simctl addmedia <device> <path> [... <path>]

You can specify multiple files including a mix of photos and videos.

You can also specify multiple live photos by providing the photo and video files. They will automatically be discovered and imported correctly.

Note (you may not need to add xcrun in front of simctl depending on how command line tools are installed).

To find the correct device id, run simctl list devices

$ xcrun simctl list devices
== Devices ==
-- iOS 10.2 --
    iPhone 5 (D226CF12-6782-4D7D-9C00-2D662CF4022C) (Shutdown)
    iPhone 5s (34E0E0F8-3429-4D91-B038-ECF4FD0F3311) (Shutdown)
    iPhone 6 (9C772A68-34E3-4F3F-981C-543DE6D5D985) (Shutdown)
    iPhone 6 Plus (7848A50E-BFB5-4F19-BB31-4A56CA78AA2C) (Shutdown)
    iPhone 6s (12CF89BA-C8B2-4837-B4EB-FB24DFF1622C) (Shutdown)
    iPhone 6s Plus (3EE6CA84-8F12-4A5E-A31D-EF4BF3CCBDB2) (Shutdown)
    iPhone 7 (1EB3CE5D-849C-491C-9CAA-5E97B1BD89CE) (Booted)
    iPhone 7 Plus (94FEFD36-6EFF-4762-BD21-79B1F958F6C6) (Shutdown)
    iPhone SE (E8E8ECEB-34C0-44F0-B92E-57DCA91024F1) (Shutdown)
    iPad Retina (0DA5BF39-3DC7-49B3-BE9B-2FA756FCA725) (Shutdown)
    iPad Air (DAB9C2D3-8EBC-41DC-9C2D-0ECEC1D2FAE3) (Shutdown)
    iPad Air 2 (1E2DA170-5C2E-413C-831B-FA65524643D3) (Shutdown)
    iPad Pro (9.7 inch) (99F931A9-0708-4637-9294-6420DC7A149C) (Shutdown)
    iPad Pro (12.9 inch) (08CD02EB-C44A-4183-961A-EED89FF1C225) (Shutdown)
-- tvOS 10.1 --
    Apple TV 1080p (7EE393F2-C83E-467F-9802-3E5BFE7C2CA9) (Shutdown)
-- watchOS 3.1 --
    Apple Watch - 38mm (B8969533-D7CD-462E-9E76-511C08E8CC8E) (Shutdown)
    Apple Watch - 42mm (E16167D9-1007-438B-8812-CD97CE6ABECA) (Shutdown)
    Apple Watch Series 2 - 38mm (F59C0BB1-B4D0-47DD-B927-1BFD78DD78C0) (Shutdown)
    Apple Watch Series 2 - 42mm (7FE3AADD-94AB-46B9-A057-78F20F030999) (Shutdown)

So to add a video to my iPhone 7 simulator, I would use:

$ xcrun simctl addmedia 1EB3CE5D-849C-491C-9CAA-5E97B1BD89CE <path to video>
George Brown
  • 1,134
  • 10
  • 25
6

With the drag and drop feature you will lose all the metadata of the photos.

I've created a project that make it really easy to import assets to the simulator: MBAssetsImporter.

It enables you to import both videos and photos while preserving all the original metadata of the files.

Mati Bot
  • 797
  • 6
  • 13
  • 1
    Great little app, this is without a doubt the best way to add photos AND videos en-mass. – Shane Aug 10 '15 at 22:16
5

This is MUCH easier with the new iOS Simulator that comes with Xcode 6+ (iOS Simulator 8.1 and above.) Now all you have to do is drag one or more photos onto the iOS Simulator window, and instead of opening Safari, the Photos app opens, and instantly adds all dragged-in photos to the device.

Donald Burr
  • 2,281
  • 2
  • 23
  • 31
0

It's simple. Just goto photos in your iPhone simulator and drag images from your location (where the images Eg.Desktop) to IphoneSimulator. It add these picture in camera album.

0

Another easy way, in High Sierra with XCode 10, with your simulator running, select your photo in Photos, go the Share menu and select "Simulator".

Voilá!

chetstone
  • 650
  • 1
  • 9
  • 19