Embedded framework objc/swift interoperability

Hi all, I'm having the following issue with objc/swift interoperability and I'm hoping you can help me out, I'm trying to use a swift class from a framework, in my app target, however they're not in the same project, the framework is built and then added to the other project manually.

So I have a huge project (InStore), that has three targets, two frameworks (InStoreCore, InStoreML) and an App Target (this is the test app for the frameworks). InStoreML has a dependency to InStoreCore, both of which have swift AND objc code.

If I try to use a swift class (ISAppBehaviour) from obj in the test app target of that project, it all works just fine, for simplicity's sake I'll put an example.

Code Block
#import <InStoreML/InStoreML-Swift.h>
/*...*/
@implementation ISExampleViewController
- (void)viewDidLoad
{
[ISAppBehaviour class];
}
/*...*/
@end


That compiles just fine, I am able to reference the swift class (ISAppBehaviour) from objc in the app target.

The issue comes when I try to use those frameworks in another project, manually embedding and linking the archived frameworks in xcode. The frameworks have these modules.modulemap

Code Block
framework module InStoreML {
 umbrella header "InStoreML.h"
 export *
 module * { export * }
}
module InStoreML.Swift {
  header "InStoreML-Swift.h"
  requires objc
}

All the headers are inside InStoreML.framework/Headers, including the autogenerated -Swift.h. Which appears to be correctly generated the same as when using it from the test app target.

Code Block
@protocol MLCAppState;
SWIFT_CLASS("_TtC9InStoreML14ISAppBehaviour")
@interface ISAppBehaviour : MLCBaseAppBehaviour
- (void)applicationIsConfiguringModules;
- (nonnull instancetype)init:(id <MLCAppState> _Nullable)state OBJC_DESIGNATED_INITIALIZER;
@end


When I try to reference ANY swift class from objc, it will throw an error, for example:

Unknown receiver 'ISAppBehaviour';


it does not fail on the import directive if I try either @import InStoreML.Swift; OR #import <InStoreML/InStoreML-Swift.h>, both work I can compile the standalone project with only the app target just fine, just as long as I don't try to actually use swift clases from objc.

To archive I tried archiving from xcode and with

xcodebuild archive -derivedDataPath $buildfolder -workspace $workspace -scheme $schemeCI -configuration $config ONLYACTIVEARCH=NO OTHERCFLAGS=-fembed-bitcode -UseModernBuildSystem=YES BUILDLIBRARIESFORDISTRIBUTION=YES -sdk iphonesimulator -archivePath "$archivefolder"/iphonesimulator.xcarchive

I see the issue with both methods.

Also checked the FRAMEWORKSEARCHPATHS and HEADERSEARCHPATHS and they appear ok.

I am using Xcode 11.6..

(And I leave a couple of screenshots of the project trying to use the frameworks)
https://share.icloud.com/photos/0KVTeY-dWvcKXxdIaFbjmlTOA

Any help is appreciated, thanks.


This appear to be an issue with BUILD_LIBRARIES_FOR_DISTRIBUTION, has anyone made this work without disabling that flag?
Embedded framework objc/swift interoperability
 
 
Q