Use of undeclared type Xcode with Cocoapods

1.7k Views Asked by At

I am trying to refer to the app delegate in a UIButton Action that is in a Pods class in my workspace, however, I keep getting the error "Use of undeclared type". I believe this is due to the App Delegate being in the other workspace project. I would like to know how to fix it? Thank you.

Button Code

@IBAction func buttonAction(sender: AnyObject) {
    let paymentViewController = storyboard.instantiateViewControllerWithIdentifier("paymentViewController") as! AddCardViewController

    let paymentPageNav = UINavigationController(rootViewController: paymentViewController)

    let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

   appDelegate.drawerContainer!.centerViewController = paymentPageNav
   appDelegate.drawerContainer!.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)
}

I get use of undeclared type for AddCardViewController, AppDelegate and MMDrawerSide.

1

There are 1 best solutions below

0
On

Had this problem with casting to custom controls from pods on my project, what solved it for me is to add import statement in the head of the file for my custom controller.

So if for example I am in MainViewController.swift and want to use a custom control/view/lib called MyCustomController imported with CocoaPods I add import MyCustomController after the import UIKit