Categories
ios language-interoperability objective-c swift xcode

Swift & Objective-C project – generated -Swift.h error – Cannot find interface declaration for UIViewController

I’ve got a project using the Swift generated Bridging Header and have the project set up correctly (no spaces in Names, Uses Modules, pre-declaring Swift classes in my .mm file, Deleting derived data, doing a clean rebuild etc…). The Bridging Header is being generated fine, but the automatically generated -Swift.h has errors in it. What’s even worse, those errors are on the generated (in project creation – Swift) versions of AppDelegate and ViewController which would normally compile fine. The errors in the -Swift.h are:

  • @interface AppDelegate : UIResponder <UIApplicationDelegate>

    >> Cannot find interface declaration for ‘UIResponder’, superclass
    of ‘AppDelegate’

    >> Cannot find protocol declaration for ‘UIApplicationDelegate’

  • @interface ViewController : UIViewController

    >> Cannot find interface declaration for ‘UIViewController’, superclass
    of ‘ViewController’

I’ve searched Stack Overflow and the net and can’t find any answer that addresses this particular issue. Has anyone else had this? Or, is there a way I can mark my AppDelegate and ViewController classes so Xcode doesn’t try and create Objective-C stubs for those Swift classes as I don’t actually need them?