We finally had success in Xcode 11 using:
- add a custom
MyFramework.modulemap
framework module MyFramework {
umbrella header "MyFramework.h"
export *
explicit module Private {
header "MyPrivateHeader.h"
header "MyPrivateOtherHeader.h"
}
}
- Mark all private headers as "Private", instead of "Project" inside your framework
- In your swift file, you can now
import MyFramework.Private
- To stop users of the framework from importing private stuff, we added a linter rule that errors on
import MyFramework.Private
while not being inside the framework project - Be aware that for this approach to work, you must import headers using
< >
brackets instead of quotes inside the (Obj-)C files in your framework. So,#import <MyFramework/MyPublicHeader.h>
and#import <MyFramework/MyPrivateHeader.h>
We also tried this with Xcode 10, but that would either crash the compiler or result in a barrage of errors