Per-project ProjectName-Swift.h, rather than per-target

Dear Experts,

I have an Xcode project that generates two iOS app targets. Most of the code is shared between the two targets. Let's call them "Project", "App1" and "App2".

I have some Swift code that is called from objC++. To make this work, in the objC++ files currently I #include "App1-Swift.h". Clearly this only works when building App1. What's the right way to set this up to work for both targets?

Looking at the build settings, currently the "Generated Header Name" is set to "$(SWIFT_MODULE_NAME)-Swift.h". Presumably, SWIFT_MODULE_NAME expands to the target name.

There are various possible ways to fix this, but which one is "right"? I bet that if I fix it in the wrong way, something else will go wrong later. I could:

  • Change the objC++ to #include different headers depending on the target being built.

  • Change the build setting to use the project name (from a variable?) instead of the SWIFT_MODULE_NAME.

  • Somehow cause SWIFT_MODULE_NAME to equal the project name, rather than the target name.

Any advice?

Thanks.

Per-project ProjectName-Swift.h, rather than per-target
 
 
Q