Swift Interop Build Issue - Linker Error with Undefined Symbols when running tests

Hi All,

I have a Swift Package I'm building. I need to import an existing C++ Static Library into this package. It seems to build fine, but when I attempt to run the tests I get a weird linker error. I've put a repro repo up at https://github.com/flighttactics/CppIssueRepro

Here's the steps I took:

  1. I have the C++ library's .a file and the headers. I created a folder in my package for the library, drug the include folder into it, and then added the .a file at the root of the folder.
  2. I created an Umbrella header in the include folder, along with a module.modulemap.
  3. I then created a shim file (per https://github.com/apple/swift-package-manager/issues/5706)
  4. Finally, I modified my package file to build the target, and reference it as a dependency

(Note I also had to go into the GeographicLib headers for DST and comment out two functions I'm not using which reference std::function since that's not supported by Swift)

I find that including the library module works in the main code base, and I can build successfully. However, when I attempt to run tests against the main code base when it's calling into the C++ library I'm getting the following build error:

ld: Undefined symbols:
  double GeographicLib::Math::AngNormalize<double>(double), referenced from:
      GeographicLib::GeoCoords::Reset(double, double, int) in CppIssueRepro.o
  GeographicLib::UTMUPS::Forward(double, double, int&, bool&, double&, double&, double&, double&, int, bool), referenced from:
      GeographicLib::GeoCoords::Reset(double, double, int) in CppIssueRepro.o
  GeographicLib::GeoCoords::MGRSRepresentation(int) const, referenced from:
      CppIssueRepro.CoordinateCalculator.coverttoMGRS(lat: Swift.Double, lon: Swift.Double) -> Swift.String in CppIssueRepro.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Again, if my main code does not call into the C++ library I'm able to run tests and build just fine.

Not sure what else I can do - it seems like I'm following everything based on the 5.9 docs but I also feel I'm maybe missing something really simple here.

Did you figure this out? I'm running into similar issues with ld: Undefined symbols

Same with me. It used to work fine. I've checked everything I know to check.

Swift Interop Build Issue - Linker Error with Undefined Symbols when running tests
 
 
Q