Swift functions with c++ enums arguments not available in c++

I'm trying to develop a mix-language (c++ and Swift) framework where calls are mainly from c++ -> Swift. However, I'm having problems with get Swift functions available in c++ when they take a c++ enum value as parameter.

Assume the following c++ header:

#pragma once

enum class MyCppEnumClass { A, B, C };
enum MyCppEnum { D, E, F };

and following Swift source file:

public func swiftFunctionWithCppEnumClass(_ value: MyCppEnumClass) {
  print("Swift function with C++ enum: \(value)")
}

public func swiftFunctionWithCppEnum(_ value: MyCppEnum) {
  print("Swift function with C++ enum: \(value)")
}

The (Xcode) project compiles correctly this way, so the bridging of the enum types does work, making both the enum and enum class available in Swift. However, when inspecting the generated Swift header, I'm seeing this:

namespace CxxInteropExperiments SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("CxxInteropExperiments") {

// Unavailable in C++: Swift global function 'swiftFunctionWithCppEnum(_:)'.

// Unavailable in C++: Swift global function 'swiftFunctionWithCppEnumClass(_:)'.

} // namespace CxxInteropExperiments

If I understand the documentation correctly, this should be supported:


The parameter is a C++ struct, class or enumeration (2nd bullet in the list), so I'd expect this to work.

Am I missing something obvious here that makes the Swift functions not available in C++.

The only workaround I can figure out is to 'mirror' the enum class on swift and write a converter function in C++, like so:

public enum MySwiftEnum {
  case A
  case B
  case C
}

public func swiftFunctionWithSwiftEnum(_ value: MySwiftEnum) {
  print("Swift function with Swift enum: \(value)")
}
#include <CxxInteropExperiments/CxxInteropExperiments-Swift.h>

CxxInteropExperiments::MySwiftEnum convert(MyCppEnumClass e) {
  switch(e) {
    case MyCppEnumClass::A: return CxxInteropExperiments::MySwiftEnum::A();
    case MyCppEnumClass::B: return CxxInteropExperiments::MySwiftEnum::B();
    case MyCppEnumClass::C: return CxxInteropExperiments::MySwiftEnum::C();
  }
}

void callSwiftFunctionWithEnum(MyCppEnumClass e) {
  CxxInteropExperiments::swiftFunctionWithSwiftEnum(convert(e));
}

Any info or advice is appreciated.

I'm using Xcode 15.3.
A sample Xcode project demonstration the issue (zip file hosted on my iCloud):