XCFramework Headers overwrite eachother when consumed by Swift Package Manager

Lets say I have 2 packages Foo1 and Foo2, each with a .binaryTarget (Foo1.xcframework and Foo2.xcframework) containing a static library and headers. I also have a package Bar which consumes Foo1 and Foo2 as dependencies. 

When Xcode builds Bar, it copies all the headers from Foo1.xcframework/ios-arm64_armv7/Headers to the include subdirectory in the build products (ex.  Debug-iphoneos/include/). It also does the same for Foo2. Their headers are all put in the same directory, potentially overwriting eachother. For example, if each has a modulemap at Headers/module.modulemap, then only one of those will end up in include/.

I can wrap all the Headers in a subdirectory, so instead of having the headers in Foo1.xcframework/ios-arm64_armv7/Headers, I could have them all in Foo1.xcframework/ios-arm64_armv7/Headers/Foo1. Then, when building Bar, the headers will end up in Debug-iphoneos/include/Foo1 and Debug-iphoneos/include/Foo2, which avoids conflicts.

Unfortunately, now the modulemap is in Debug-iphoneos/include/Foo1/module.modulemap and Xcode doesn't know to look there for module maps, so it fails to import. I can fix this on the command line by modifying the search paths, but I can't modify search paths when opening Bar's Package.swift in Xcode.

Where can I put the modulemap and other headers so that Xcode can find them without them conflicting with eachother?

My suggestion would instead be to manually assemble your library, headers and module map into a framework structure to namespace it that way and avoid any conflicts. I would do that prior to running xcodebuild -create-xcframework and pass the frameworks you created to that command.

I know its been a year, but have you found a solution for this? I'm facing a similar issue.

I know its been a year but have you found a solution for this issue? The reply from the dev tools engineer is unacceptable IMO.

XCFramework Headers overwrite eachother when consumed by Swift Package Manager
 
 
Q