One question that gets asked frequently in iPhone developer forums is, ‘How do I add photos to the Camera Roll in the iPhone Simulator?’ The most-quoted solution is to drag an image onto the simulator window. This will open it in Mobile Safari from where you can save it to the Camera Roll by tapping and holding on the image. This is fine if you just need one or two images, however, if you need to load a large number of photos into the simulator then this one-by-one approach is going to get very tired very quickly. We hit this problem while developing an app for a client that includes a custom photo browser and we needed to load 100s of photos during testing.
The Simulator
Other approaches involve copying image files directly into the Simulator under its Media directory at [home]/Library/Application Support/iPhone Simulator/4.x/Media. However, copying images directly into the Simulator can lead to problems with missing thumbnails or images just not appearing at all in the Photos app or Image Picker.
Our solution was to write an iPhone app designed to run in the Simulator that performs a bulk import of image files from disk. The app leverages iOS support for saving photos to the user’s Camera Roll, which ensures that thumbnails are generated correctly and the Photo database is updated.
The Image Importer app
OK, so it’s not pretty, but it does the job. All you need to do is download the Xcode project at the bottom of this article, build it and run it in the iPhone Simulator.
Once the app is running just follow the instructions. Copy images that you want to import into the folder shown (jpg or png). The default location is a folder called ‘iPhone Images’ under your Pictures folder but you can change this if needed. Click the ‘Import’ button and wait. All being well, your images should now appear correctly in the Photo app. They will also be available through the Image Picker API and the new ALAssetsLibrary API in iOS4.0.
We’d love to hear if you have found this article useful – leave a comment.
Update: Some people are seeing a ‘Data Unavailable’ error. To fix this choose “Reset Content and Settings…” from the iPhone Simulator menu.
If you are still receiving the same error after this then:
- Drag and drop an image onto the simulator to open it in Mobile Safari
- Click on the image and hold
- Choose “Save Image”
- Open the Photo app in the simulator to rebuild your photo library

{ 27 comments… read them below or add one }
Very nice tool!!! thanks…
Just a little problem in the zip: the resource image “aptogo.png” was missing and the project didn’t build properly. I just removed it and all is working fine…
Cheers
magi
Hi Magi,
Glad you like the tool. I’ve updated the project to include the resource image. Thanks for pointing this out.
Thanks very much
. I was getting the error “Data Unavailable” on the Import, but after I did iPhone Simulator > Reset Contents and Settings, it worked a treat.
Thanks for the sample.
Anyhow, it doesn’t work if there is no pictures in the library yet : “Data Unavailable” error
I had to drag and drop an image in the simulator, then click on it and hold, and finally choose “save image”
That creates a new library and after that everything worked well.
thanks so much for writing this handy little utility! it really does help out a TON!
rocksteady,
danno~
doesn’t work. Data Unavailable error.
See the new update at the end of the article about how to fix this.
Mahalo Robin, worked like a charm.
Hi Robin,
Great tool. Worked nice for me at the first try itself. Thanks
Thank you! It works, but path to the folder for import must be without white spaces:
iPhone Images -> iPhoneImages
Strange – it works with folders with space in for me!
I’m using the 4.2 SDK and I get the “Data Unavailable” error every time. I tried both resetting the settings and saving an image and still have the problem. Any other ideas? Thanks!
You need to open the Photo app in the simulator once you have saved an image from Safari. You should see a progress bar with a message indicating that the photo library is being rebuilt. It should work after this.
That worked, thanks! This app was just what I needed!
Thanks so much for sharing this. I would have been fine with adding single images, but 4.2 isn’t playing nice. Your app works perfect. Thanks again.
I have a small idea to implement the same with IOS 3.x & may be for earlier too.
However some slight modification must help.
1. Ask user to run this app in simulator once and then exit.
2. Now ask him to navigate to /Library/Application Support/iPhone Simulator/x.x/
3. Now he have too look in all the directories for ImageImporter.app file.
4. Once he found he can copy all the picture files to documents folder.
5. The next time when opens the app you can just check for no.of.files in Documents directory and start process of importing from documents directory.
6.finally let him exit the app and start photos application.
So,that way you can give 2 downloadables for ios x.x & 4.x
This is just a suggestion, Im sorry if you have already tried this one.
Hi,
Not sure I follow you. The app works with iOS 3.x already. In fact the UIImageWriteToSavedPhotosAlbum function that is the key to saving photos into the camera roll on the simulator has been around since OS2.0.
Robin
Hi,
just a big thank you. Spared me a sleepless night.
Thank you for the utility, works great. You might want to change the label that reads “Add images to this folder” to “Copy images FROM this folder”
Thanks so much for this! For some reason saving through safari wasn’t working properly for me. This is an even better solution! BTW, I initially had the error of Data Unavailable and the “Reset Content and Settings” didn’t fix it. I removed the space in the directory path and change it in the path in the app and then it worked like a charm. Life saver
Very useful. Safari does not always save images correctly on the simulator. This app does the trick !!!
Thanks for the app!
As a follow up to the ‘data unavailable’ error, I spent 20 minutes wondering why it was happening and discovered it was because I had a model view open in Xcode.
As soon as I switched to a class view the problem ceased.
Many thanks!
I appreciate this tool, thanks!
Very useful to import many photos in one go. Thanks a lot.
Oh so useful. Thanks heaps for sharing!
Nice one – great tool!