Swift: Add option to set default cxx-interoperability-mode
With Swift 5.9/Xcode 15 they have added more C++ Interop features.
The -enable-experimental-cxx-interop
flag has been replaced with -cxx-interoperability-mode=default
or -cxx-interoperability-mode=off
$ swiftc --help | grep interop -cxx-interoperability-mode= Enables C++ interoperability; pass 'default' to enable or 'off' to disable
However, setting this flag on a swift target has no impact on a generated Xcode project. The project should have the C++ and Objective C Interoperability
setting set to "C++/Objective C++" rather than the default "C/Objective C". Turns out the default mode is not "default" but "off"
Should there be a global setting to set this flag on the project builtin to CMake? Or is it my responsibility to set the Xcode property on my swift target manually?
Here's an example that uses the feature that I forked and updated for Xcode 15.
https://github.com/ADKaster/swift-cmake-examples/tree/xcode-15/Interop
Note that I used this example in an upstream bug report here https://github.com/apple/swift/issues/68726, pointing out that the C++20 char8_t struct member is dropped on the floor when used.