My current project contains both Swift and Objective-C code. Both types of source file use code from the other language.
When I do a full clean and recompile, I get errors on almost every single Swift class declaration in Module-Swift.h
, of the form:
Cannot find interface declaration for 'UIViewController', superclass of 'CustomViewController'
My symptoms are similar to this question, in similar circumstances to this question. In other words:
Module-Bridging_Header.h
imports my Objective-C header,Class.h
- The implementation file
Class.m
imports the Swift header,Module-Swift.h
If I follow the approach in the ansewrs to this question, I can resolve the error by adding the following file, and importing that in place of Module-Swift.h
:
//
// Module-Swift-Fixed.h
// Module
//
#ifndef Module_Swift_Fixed_h
#define Module_Swift_Fixed_h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <UIKit/UIKit.h>
#import "Module-Swift.h"
#endif /* Module_Swift_Fixed_h */
This seems like a horrible hack. Am I missing some proper way to achieve this in Xcode?