0

I'm new to the coding industry and am seriously struggling with Swift. I have a situation where I want to go from one page to another, but I keep getting an error of "use of undeclared type AVCamViewController. This is my code:

@IBAction func goToApp(sender : AnyObject) {
        let AVCam = self.storyboard.instantiateViewControllerWithIdentifier("AVCam") as? AVCamViewController.h
        self.navigationController.pushViewController(AVCam, animated: true)
    }

And if I try to import the AVCamViewController or AVCamViewController.h or AVCamViewController.m, I get an error of 'no such module'.

I have have all the files of the AVCam application in my app so I am not sure what to do. Any advice please?

pnuts
  • 58,317
  • 11
  • 87
  • 139
RPMouton
  • 161
  • 1
  • 1
  • 6

2 Answers2

0

You need to remove .h from line when you instantiate vc:

let AVCam = self.storyboard.instantiateViewControllerWithIdentifier("AVCam") as? AVCamViewController

AVCamViewController.h is file name but you need class name which is AVCamViewController

Greg
  • 25,317
  • 6
  • 53
  • 62
0

Do you have a bridging header set up? If AVCamViewController is a system class, you have to @import the right framework, i.e. @import AVFoundation. Otherwise, you have to create a header specifically for use as a bridge from Objective C to Swift. In said header, you include your own headers that you want Swift to see. You will have to set the build settings to point to the new header. If you added a new Swift class/file, Xcode should have asked if it could create one automatically. If you do have one, you can put your header imports/includes into that file.

MaddTheSane
  • 2,981
  • 24
  • 27