objective-cswiftxcodeobjective-c-swift-bridge

In a mixed objc/swift module, Xcode always tries to include the module itself


This one is not easy to explain, but is also very annoying.

I'm working on a Cocoapods framework (in development mode) with objc and swift sources. Let's call it the "SuperCompoment" framework

Xcode auto generates the SuperComponent-Swift.h file, to make Objc classes visible from Swift ones.
Some Objc classes also includes Swift classes.

At compile time, in the SuperComponent-Swift.h, Xcode adds the line

#import <SuperComponent/SuperComponent.h>

... and fails to compile with the message: SuperComponent/SuperComponent.h file not found

Xcode tries to include the framework inside the framework itself!

If I manually edit the auto-generated file by commenting the #import, the project compiles perfectly. But Xcode auto-generates the file after each clean and before archiving the project!

Any clue?


Solution

  • I don't know why Xcode automaticaly adds the #import <SuperComponent/SuperComponent.h> line (since it do work without it), but if i'm kind with him by adding an empty SuperComponent.h file at the root of my framework, it compiles gracefully.