Unknown type name for swift property

ios, swift, xcode6

Solution

In your Objective-C code, you are somewhere importing the automatically generated `-Swift.h` header. In that same code, before that `#import` line, insert `#import "CustomNavigationController.h"`. The order of these two `#import` statements is crucial!

This will solve the problem by making sure that CustomNavigationController is in the namespace before the automatically generated `-Swift.h` header, and so the latter will know about the former and all will be well.

This is something of an annoyance if that Objective-C class had no need to know about CustomNavigationController, but it solves the problem going forward and allows you to continue to work with your hybrid project.

Problem

I have a CustomViewController class written in swift and a CustomNavigationController class written in Objective C. I'm trying to add my CustomNavigationController as a property to my CustomViewController. I've added `#import "CustomNavigationController.h"` to my bridging header. In my CustomViewController I have: ``` class CustomViewController: UIViewController { var navController: CustomNavigationController? ... //init methods ... override func viewDidLoad() { super.viewDidLoad() //Set up Navigation Controller navController = self.storyboard.instantiateViewControllerWithIdentifier("CustomNavigationController") as CustomNavigationController! } ``` There are no errors until I try to build and run...I get "unknown type name 'CustomNavigationController'; did you mean 'UINavigationController'?" Does anyone know why it doesn't recognize the type?

Original source

Related problems