Camera does not work with Xocde13.3.1

I am trying to make a simple camera app. But when I execute the code with iOS simulator, the iphoe show only black image and appear anything.

I made it with the code below and two permissions which are Privacy - Camera Usage Description and Privacy - Photo Library Additions Usage Description.

I need some help for solving this.

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

  @IBOutlet weak var imageView: UIImageView!
  @IBAction func launchCamera(_ sender: UIBarButtonItem) {
    let camera = UIImagePickerController.SourceType.camera
    if UIImagePickerController.isSourceTypeAvailable(camera){
      let picker = UIImagePickerController()
      picker.sourceType = camera
      picker.delegate = self
      self.present(picker, animated: true)
    }
  }
   
  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
     
    let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage
    self.imageView.image = image
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
    self.dismiss(animated: true)
  }
   
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
  }

The Simulator does not have a camera!
Only real device have cameras.

Your code may well be fine.
Try running it on a real iPhone or iPad, and see if it works.

Note: Your code checks "isSourceTypeAvailable(camera)", but you don't take any action if the sourceType is not available.
If you (for example) logged an error message to the console, then you would have noticed that your app was not detecting a camera.

Camera does not work with Xocde13.3.1
 
 
Q