In a framework project with mixed Swift/ObjC code, generating the ObjC header fails because of circular dependency on itself

I am trying to build a framework which contains both ObjC and Swift code (this is a repackaging of existing code). I'm modelling my approach on GitHub - armadsen/mixed-swift-objc-framework: Shows how to mix Swift and Objective-C code inside a framework target, except I have a lot more code to deal with. It works reasonably well so far, adding code to it works, but I'm blocked by a problem with the generation of the ObjC header for the Swift code. At the step generating this header (MyFramework/MyFramework-Swift.h), I get this error :

error: Clang dependency scanner failure: While building module 'MyFramework' imported from MyFramework-0ab317d8.input:1:
In file included from :1:
In file included from /Users/glaurent/Developer/MyFramework/MyFramework/MyFramework.h:57:
/Users/glaurent/Developer/MyFramework/MyFramework/LSUniversalBase/include/SomeRandomHeader.h:14:9: fatal error: 'MyFramework/MyFramework-Swift.h' file not found
/Users/glaurent/Developer/MyFramework/MyFramework/LSUniversalBase/include/SomeRandomHeader.h:14:9: note: did not find header 'MyFramework-Swift.h' in framework 'MyFramework' (loaded from '/Users/glaurent/Library/Developer/Xcode/DerivedData/MyFramework-fqnakdemtwsvsubsnfeqyslrvhtt/Build/Products/Debug-iphoneos')
MyFramework-0ab317d8.input:1:1: fatal error: could not build module 'MyFramework'

Several ObjC headers include MyFramework-Swift.h, and obviously since it's not there yet it can't find it, but why does generating the ObjC Swift header needs to look into the existing headers ? Of course this doesn't happen in an app project. The only way I have found to unlock this is to change the name of the imported Swift header to something else (import <MyFramework/Custom-MyFramework-Swift.h>) with the Custom-MyFramework-Swift.h being even empty, it just needs to exist. Then the header will be properly generated, and I can copy it in place of Custom-MyFramework-Swift.h.
I have tried to create an empty MyFramework-Swift.h file in the appropriate DerivedData folder, but that doesn't work, the same error persists.

Any ideas ?

I think the issue is that you cannot include MyFramework-Swift.h in the umbrella header. So, any Objective-C client of your framework would need to import either

#import <MyFramework/MyFramework.h>
#import <MyFramework/MyFramework-Swift.h>

or

@import MyFramework;

Ok, I don't include MyFramework-Swift.h in the umbrella header (so MyFramework.h), but it does include headers which in turn include the -Swift.h header. So I guess I need to find a way to avoid that... Thank you for your help :).

One option here is to switch the declarations of Swift classes that you need to include in public headers to Objective-C, while using @objc @implementation to keep the implementation in Swift. One potential concern with this is that you can no longer have overridable methods that use non-Obj-C-compatible types on the class. But if you’re just using the class as-is without subclassing there won’t be an issue.

Thanks, I'll keep that in mind but it seems I managed to get a build working. I'm currently stuck on a different problem (a bitstrip command applied to a lib.a which is part of my framework and which fails when trying to launch a sample app using my framework), but the Framework-Swift.h issue is solved.