Adding photos to the iPhone Simulator

May 16, 2012 08:45 · 180 words · 1 minute read

If you’re testing photo functionality in the iPhone Simulator that involves picking images from the Photo Library, you’re going to come up against the apparently existential problem of how to get photos into the Library when the Simulator doesn’t have a camera.

The solution is simpler than I’d thought it would be.  Stop your app, and fire up Safari in the Simulator.  Then find the image you want to use from the Mac filesystem, and drag it over onto the Simulator and drop it into Safari.

Safari will open it as a file://foo.jpg-style URL.  Then click and hold on the image until an action sheet appears (that’s a “long press” in finger terms).  Click the Save Image button, and the image will be saved into the Simulator’s Photo Library.  The next time you run an app that uses the Library, the image you’ve just saved will be in there as if it had been taken with the camera.

The Simulator’s Photo Library won’t persist beyond a simulator reset, but it’s quick enough to add a few images back in again.