Cpp interop on windows not finding swift/bridging

Hi,

I'm trying to make a cross platform app for Mac and Windows (and eventually Linux), using the new cxx-interop to call a 3rd party cpp library. I have this all working great on Mac (via SPM) and mostly working on Windows... but when I try to #include <swift/bridging> in my cpp code, I get a compile error on windows.

fatal error: 'swift/bridging' file not found

Where is that header located on non-mac platforms?

Thanks,
mike

Unfortunately, reports like this are very useful but rarely encountered :frowning:

This header was missed in the 5.9 release cycles. I think that we should try to fix this for the next cycle. The fix for this is already in 5.10, and hopefully once we have official builds, that should be included. In the mean time, you can either try to build a release yourself. There is some work that The Browser Company is doing to get 5.10 builds going in the mean time, so that might become an option shortly while we are waiting on official builds.

2 Likes

Thanks for the info... I'm glad it's a known issue. Do you know the extent of the missing functionality? Is it just a matter of making a copy of the header in the project? That seems to still work on Mac, but on Windows I still fail compilation but in an actual compiler crash when trying to use the cpp object annotated with the swift bridging attributes (specifically SWIFT_SHARED_REFERENCE)

mike

I’m only aware of the missing header. If there’s a crash, that’s new information. Do you have a reproduction that we can use? It would be good to check if this is still occurring on main and release/5.10.

Once we have information on the crash, we can look into what is needed and try to get it repaired.

I'll try to put together a simplified project that reproduces the crash over the holiday break.

3 Likes

Sorry for reviving the old thread, but I've just run into this myself:

PS E:\sandbox\compositorapp\compositor\Sources\Core> swift build -Xswiftc -suppress-warnings 
...
[1/1] Planning build
Building for debugging...
In file included from E:\sandbox\compositorapp\compositor\Sources\Core\Sources\cppbridge\TexTypes.cpp:8:
E:\sandbox\compositorapp\compositor\Sources\Core\Sources\cppbridge\include\TeXTypes.h:13:10: fatal error: 'swift/bridging' file not found
   13 | #include <swift/bridging>
      |          ^~~~~~~~~~~~~~~~
1 error generated.

I am on the most recent TBC toolchain:

> swift -version
compnerd.org Swift version 6.2-dev (LLVM 8bdbd74d77951ad, Swift 63b7f05d749d48f)
Target: aarch64-unknown-windows-msvc
Build config: +assertions

You need to explicitly add that to your search path.

swift build -Xcc "-I$(Join-Path (Split-Path (Split-Path (Get-Command swiftc).Source)) "include")"
1 Like

Yes, that worked, thanks a lot!

Yeah, I do encounter this issue on linux too

1 Like