XCFramework "Cannot load underlying module"

Viewed 366

I've built an SDK as an XCFramework, which shares dependencies with the app that uses it. When I build, I'm getting:

...SDK.swiftmodule/arm64-apple-ios.swiftinterface:20:8: Cannot load underlying module for...

This occurs in the Compile Swift Sources action and the break is in the import MySharedDepedency statement in the swiftinterface file

As stated, the SDK in the project as an xcframework bundle. MySharedDependency is fulfilled with cocoapods. use_modular_headers is set in the Podfile, it's modulemap is included in the linker flags (by cocoapods).

Its DOES work if I use the use_frameworks! flag in the Podfile but only with dynamic linkage and for internal politics reasons, I need this to work with static linkage. If I add the :linkage => :static argument, I get the same error as with no use_frameworks! call

I've tried changing the order of the linked frameworks in Build Phases (so that the pods are linked before the SDK framework). I've tried adding recursive header/framework/module search paths everywhere I can find a MyDependency.modulemap...

Yes, I've cleaned caches, deintegrated, clean installed, erased deriveddata, restarted xcode, my machine, ...

Argh! Thanks for any help...

1 Answers

I had the same exactly the same scenario and the same problem

I solved using @_implementationOnly in every file from my xcframework's code like:

@_implementationOnly import Alamofire

After that just rebuild your XCFramework, clean and build your app's project.

It works like a charm without use_frameworks!

Related