iOS simulator crashes when opening image picker with source type .savedPhotosAlbum or .photoLibrary [duplicate]

iOS simulator crashes when opening image picker with source type .savedPhotosAlbum or .photoLibrary [duplicate]

This question already has an answer here:

I am working my way through the apple tutorial on building iOS apps to get myself started in this scene. I reached the point where I am instructed to create a UIImagePickerController with a source type .photoLibrary. here is the code to do so:

 @IBAction func selectImageFromPhotoLibrary(_ sender: UITapGestureRecognizer) {

        // Hide the keyboard.
        nameTextField.resignFirstResponder()

        // UIImagePickerController is a view controller that lets a user pick media from their photo library.
        let imagePickerController = UIImagePickerController()


        // Only allow photos to be picked, not taken.
        imagePickerController.sourceType = .photoLibrary

        // Make sure ViewController is notified when the user picks an image.
        imagePickerController.delegate = self

        present(imagePickerController, animated: true, completion: nil)

    }

when I run the simulator the view loads fine, but when I tap the image which is supposed to trigger the display of the image picker the app crashes. I tried switching the source type to .savedPhotosAlbum as I read this may be the issue, but it didn’t solve the problem. I am running xcode8. Thoughts?