iOS simulator gives error on takePicture method


I haven’t actually started Chapter 11 yet but decided to run the code from the online solutions. When I click on the camera icon the takePicture method executes setting the sourceType (correctly) to UIImagePickerControllerSourceTypePhotoLibrary. After exiting the method an alert pops up with the following text:

This app does not have access to
your photos or videos.
You can enable access in Privacy Settings.

I’ve already spent too much time trying to see find out what is happening with the code from the online solutions. Anyone have any idea what’s going on? I’d sure like to know before I spend a lot of time with my own code trying to get this to work. This seems like a problem that someone else should have seen but no mention in this or the 3rd edition discussion.

Using xCode 5.1 and iOS Simulator 7.1 on MacBook Air with OS X 10.9.2.

Thanks in advance for saving me some time.


Each app has to give explicit permission to access things such as photos, location, contacts, microphone, and a few others. What this error is saying is at some point, you denied the app permission the first time it asked.

The easiest way to fix this issue is to reset the simulator. From the “iOS Simulator” menu item, select “Reset Content and Settings…” and then re-run the application. When you attempt to show the photo library, you should get the original prompt again that you’ll be able to accept.


Thanks for the quick response. Actually, I had already reset the simulator once. I then used Safari to save some images before running the chapter 11 code. I got the same alert. Just now I reset and ran the code without loading images first - same alert. Interesting, huh? BTW the Safari loaded images work fine in the simulator Photo app except that the app crashes if I click on the Edit button.

I should mention that I have never seen a request for permission to access photos no matter what I have done.


Well, this just curiouser and curiouser. I just downloaded fresh copies of Xcode and the solutions onto my iMac. It works! I got the permission request and then images in the library showed up just fine. I’m going to try fresh downloads on the MacBook Air to see what happens.


A fresh Xcode eliminated the problem. Apparently something was corrupted. Now I can start Chapter 11.