title: SwiftyCam capture session is not running
body: <p>I have created my camera view following the demo project on GitHub from <a href="http://github.com/Awalz/SwiftyCam" rel="noreferrer">SwiftyCam</a> Everything lays out correctly and is going well; however, when the camera button is pushed I get a message in the console saying "[SwiftyCam]: Cannot take photo. Capture session is not running". There have been other people having this problem with swift 4 and you can find that <a href="http://github.com/Awalz/SwiftyCam/issues/117" rel="noreferrer">here</a>. I have gone through the whole framework line by line but for some reason I can't figure it out. I would really appreciate it if someone could look at the framework and the documentation and help me out. The way I'm doing it is just about exactly how it's done in the Swift 4 <a href="http://github.com/Awalz/SwiftyCam/tree/Swift4/DemoSwiftyCam/DemoSwiftyCam" rel="noreferrer">demo project</a> so that would be the code reference. </p>
  
  <p>Thank you in advance</p>
  
  <p>EDIT: Below is the code when setting up the SwipeNavigationController after the WelcomeVC</p>
  
  <pre><code>let swipeNavigationController = SwipeNavigationController(centerViewController: CameraViewController())
  
      swipeNavigationController.topViewController = BlueView()
      swipeNavigationController.bottomViewController = PinkView()
      swipeNavigationController.leftViewController = OrangeView()
      swipeNavigationController.rightViewController = GreenView()
  
  
  
      cameraView.navigationController?.setNavigationBarHidden(true, animated: false)
  
  
      orangeView.navigationController?.setNavigationBarHidden(false, animated: false)
  
      greenView.navigationController?.setNavigationBarHidden(false, animated: false)
  
  
  
  
  
      let navController = UINavigationController(rootViewController: swipeNavigationController)
  
      self.present(navController, animated: true, completion: nil)
  </code></pre>
  
  <p>Below is all the code in the CameraVC</p>
  
  <pre><code>    class CameraViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate, SwipeNavigationControllerDelegate {
  
  
  
  
      let orangeVC = OrangeView()
  
      let greenVC = GreenView()
      let blueVC = BlueView()
      let pinkVC = PinkView()
  
  
  
      let flipCameraButton: UIButton = {
          let button = UIButton()
          let image = UIImage(named: "cameraSwitch")
          button.setImage(image, for: .normal)
          button.addTarget(self, action: #selector(cameraSwitchTapped), for: .touchUpInside)
  
          return button
      }()
  
      let captureButton: SwiftyRecordButton = {
          let button = SwiftyRecordButton(frame: CGRect(x: 150, y: 572, width: 75, height: 75))
          //let image = UIImage(named: "focus")
          //button.setImage(image, for: .normal)
          //button.addTarget(self, action: #selector(cameraTapped), for: .touchUpInside)
  
  
  
  
          return button
      }()
  
  
  
      let orangeButton: UIButton = {
          let button = UIButton()
          let image = UIImage(named: "OrangeIcon")
          button.setImage(image, for: .normal)
          button.addTarget(self, action: #selector(goToOrange), for: .touchUpInside)
  
          return button
      }()
  
      let greenButton: UIButton = {
          let button = UIButton()
          let image = UIImage(named: "GreenIcon")
          button.setImage(image, for: .normal)
          button.addTarget(self, action: #selector(goToGreen), for: .touchUpInside)
  
          return button
      }()
  
      let pinkButton: UIButton = {
          let button = UIButton()
          let image = UIImage(named: "pinkCameraIcon")
          button.setImage(image, for: .normal)
          button.addTarget(self, action: #selector(goToPink), for: .touchUpInside)
  
          return button
      }()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          view.addSubview(flipCameraButton)
          view.addSubview(captureButton)
          view.addSubview(orangeButton)
          view.addSubview(greenButton)
          view.addSubview(pinkButton)
  
          shouldPrompToAppSettings = true
          cameraDelegate = self
          maximumVideoDuration = 10.0
          shouldUseDeviceOrientation = true
          allowAutoRotate = true
          audioEnabled = true
  
  
          // disable capture button until session starts
          captureButton.buttonEnabled = false
  
          navigationController?.isNavigationBarHidden = true
  
              UIApplication.shared.statusBarStyle = .lightContent
              navigationController?.isNavigationBarHidden = true
  
          setupViews()
  
      }
  
  
      override func viewWillAppear(_ animated: Bool) {
          UIApplication.shared.statusBarStyle = .lightContent
          navigationController?.isNavigationBarHidden = true
  
      }
  
      override func viewDidAppear(_ animated: Bool) {
          super.viewDidAppear(animated)
          captureButton.delegate = self
  
      }
  
  
      //
  
  
      @objc func goToOrange() {
  
  
          orangeVC.navigationController?.setNavigationBarHidden(false, animated: true)
  
          self.containerSwipeNavigationController?.showEmbeddedView(position: .left)
      }
  
      @objc func goToGreen() {
  
  
          greenVC.navigationController?.setNavigationBarHidden(false, animated: true)
  
          self.containerSwipeNavigationController?.showEmbeddedView(position: .right)
  
  
      }
  
      @objc func goToPink() {
  
  
          self.containerSwipeNavigationController?.showEmbeddedView(position: .bottom)
      }
  
      @objc func cameraSwitchTapped() {
          switchCamera()
      }
  
      @objc func cameraTapped() {
          print("CAMERA TAPPED")
  
          takePhoto()
      }
  
  
  
  
      func setupViews() {
  
          flipCameraButton.anchor(top: view.topAnchor, left: nil, bottom: nil, right: view.rightAnchor, paddingTop: 25, paddingLeft: 0, paddingBottom: 0, paddingRight: 12, width: 35, height: 35)
  
          captureButton.anchor(top: nil, left: nil, bottom: pinkButton.topAnchor, right: nil, paddingTop: 0, paddingLeft: 0, paddingBottom: 10, paddingRight: 0, width: 75, height: 75)
         captureButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
  
          orangeButton.anchor(top: nil, left: view.leftAnchor, bottom: view.bottomAnchor, right: nil, paddingTop: 0, paddingLeft: 10, paddingBottom: 0, paddingRight: 0, width: 75, height: 75)
  
          greenButton.anchor(top: nil, left: nil, bottom: view.bottomAnchor, right: view.rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 10, width: 75, height: 75)
  
          pinkButton.anchor(top: nil, left: nil, bottom: view.bottomAnchor, right: nil, paddingTop: 0, paddingLeft: 0, paddingBottom: -10, paddingRight: 0, width: 75, height: 75)
          pinkButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
  
          view.addSubview(flipCameraButton)
          view.addSubview(captureButton)
          view.addSubview(orangeButton)
          view.addSubview(greenButton)
          view.addSubview(pinkButton)
      }
  
  
  
      //MARK: Camera Protocols
  
      func swiftyCamSessionDidStartRunning(_ swiftyCam: SwiftyCamViewController) {
          print("Session did start running")
          captureButton.buttonEnabled = true
      }
  
      func swiftyCamSessionDidStopRunning(_ swiftyCam: SwiftyCamViewController) {
          print("Session did stop running")
          captureButton.buttonEnabled = false
      }
  
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didTake photo: UIImage) {
          let newVC = AfterPhotoTakenView(image: photo)
          self.present(newVC, animated: true, completion: nil)
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didBeginRecordingVideo camera: SwiftyCamViewController.CameraSelection) {
          print("Did Begin Recording")
          captureButton.growButton()
          hideButtons()
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didFinishRecordingVideo camera: SwiftyCamViewController.CameraSelection) {
          print("Did finish Recording")
          captureButton.shrinkButton()
          showButtons()
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didFinishProcessVideoAt url: URL) {
          let newVC = VideoView(videoURL: url)
          self.present(newVC, animated: true, completion: nil)
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didFocusAtPoint point: CGPoint) {
          print("Did focus at point: \(point)")
          focusAnimationAt(point)
      }
  
      func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController) {
          let message = NSLocalizedString("Unable to capture media", comment: "Alert message when something goes wrong during capture session configuration")
          let alertController = UIAlertController(title: "AVCam", message: message, preferredStyle: .alert)
          alertController.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Alert OK button"), style: .cancel, handler: nil))
          present(alertController, animated: true, completion: nil)
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didChangeZoomLevel zoom: CGFloat) {
          print("Zoom level did change. Level: \(zoom)")
          print(zoom)
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didSwitchCameras camera: SwiftyCamViewController.CameraSelection) {
          print("Camera did change to \(camera.rawValue)")
          print(camera)
      }
  
      func swiftyCam(_ swiftyCam: SwiftyCamViewController, didFailToRecordVideo error: Error) {
          print(error)
      }
  
  
  
  
  
  
  
  
      override var preferredStatusBarStyle: UIStatusBarStyle {
          return .lightContent
      }
  
  
  }
  
  
  
  
  extension CameraViewController {
  
      fileprivate func hideButtons() {
          UIView.animate(withDuration: 0.25) {
  
              self.flipCameraButton.alpha = 0.0
          }
      }
  
      fileprivate func showButtons() {
          UIView.animate(withDuration: 0.25) {
  
              self.flipCameraButton.alpha = 1.0
          }
      }
  
      fileprivate func focusAnimationAt(_ point: CGPoint) {
          let focusView = UIImageView(image: #imageLiteral(resourceName: "focus"))
          focusView.center = point
          focusView.alpha = 0.0
          view.addSubview(focusView)
  
          UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: {
              focusView.alpha = 1.0
              focusView.transform = CGAffineTransform(scaleX: 1.25, y: 1.25)
          }) { (success) in
              UIView.animate(withDuration: 0.15, delay: 0.5, options: .curveEaseInOut, animations: {
                  focusView.alpha = 0.0
                  focusView.transform = CGAffineTransform(translationX: 0.6, y: 0.6)
              }) { (success) in
                  focusView.removeFromSuperview()
              }
          }
      }
  
      fileprivate func toggleFlashAnimation() {
          if flashEnabled == true {
              //flashButton.setImage(#imageLiteral(resourceName: "flash"), for: UIControlState())
          } else {
              //flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState())
          }
      }
  }
  </code></pre>
  
  <p>This is what it looks like when a user swipes to another view, as well as the buttons aren't responsive and the user can't swipe up or down for those views either. </p>
  
  <p><a href="https://i.stack.imgur.com/JHDU5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/JHDU5.jpg" alt="enter image description here"></a></p>
  
  <p>Here is an example of a view I'm trying to present when the user swipes from left to right or clicks the pink messages button. </p>
  
  <pre><code>class MessagesView: UITableViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  
      view.backgroundColor = UIColor.white
  
      setupNavBar()
  
      navigationController?.isNavigationBarHidden = false
  
      if #available(iOS 11.0, *) {
          navigationController?.navigationBar.prefersLargeTitles = true
          self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
      } else {
          // Fallback on earlier versions
      }
  
  
  }
  
  override func viewWillAppear(_ animated: Bool) {
  
      if #available(iOS 11.0, *) {
          navigationController?.navigationBar.prefersLargeTitles = true
          self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
          setupNavBar()
      } else {
          setupNavBar()
      }
  }
  
  func setupNavBar() {
      UIApplication.shared.statusBarStyle = .lightContent
      self.navigationController?.isNavigationBarHidden = false
      self.navigationController?.navigationBar.topItem?.title = "Messages"
      self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
      self.navigationController?.navigationBar.barTintColor = UIColor.pinkNeonColor
      self.navigationController?.navigationBar.tintColor = UIColor.white
  }
  </code></pre>
  
  <p>}</p>