Trying to import Swift code from one target to Objective C target in same library can't find Swift header

Did you ever resolve this? I'm having the same issue.

I was able to hack around it and get it to compile by adding the following to the ObjC target:

cSettings: [.unsafeFlags(["-I./build/GeneratedModuleMaps-iphoneos"])]

however this is not great for a number of reasons, including the explicit iphoneos in the path (what if I wanted to build for another OS?) and the general usage of .unsafeFlags. It seems like SPM should be adding this line itself. I tried using .headerSearchPath to set this in a "safer" manner but that didn't work.

When I compile with xcodebuild, I can see that lots of -I args are getting added, just not one that lets it find the generated header file. It's even adding -fmodule-map-file arguments that point to generated module map files in that same directory, but it's not adding the -I to allow the compiler to find the header there.

I also took a look at the SPM source at https://github.com/apple/swift-package-manager/blob/main/Sources/Build/BuildPlan/BuildPlan%2BClang.swift#L23-L28 and it appears there's no code to add the -I flag for the generated Swift header when planning a ClangTarget if the underlying dependency target is a SwiftTarget.