Is there a way to detect C++ interoperability mode at compile time? CFSocketCallBackType is tricky and I can’t find a syntax that works with both C++ interop and without.
I tried canImport(CxxStdLib) but that passes both modes, even though without C++ importing it fails with “Cannot load underlying module”, which maybe seems like a bug?
Detecting C++ interoperability mode at compile time is tricky since #canImport(CxxStdlib) checks module existence, not actual interop status. A reliable workaround is using a custom compiler flag (e.g., -DCPP_INTEROP_ENABLED) set in your build settings and then checking with if CPP_INTEROP_ENABLED to conditionally compile C++-dependent code.