I've figured out how to generate C++ headers from my Swift files. Now I'm running into some compile errors when I try to use them in C++ code. The compiler very understandably complains that "Functions that differ only in their return type cannot be overloaded" here:
SWIFT_INLINE_THUNK Key getKey() const;
SWIFT_INLINE_THUNK swift::Optional<Key> getKey() const;
This is from the translation of this fairly simple enum:
public enum Element {
case key (Key)
case index (Int)
public var key: Key? {if case let .key(key) = self {key} else {nil}}
public var index: Int? {if case let .index(index) = self {index} else {nil}}
}
Another example is
SWIFT_INLINE_THUNK Value operator [](swift::Int i) const;
SWIFT_INLINE_THUNK swift::Optional<Value> operator [](swift::Int i) const;
That one's caused by overloaded subscripts in a struct:
public subscript(i: Int) -> Value {...}
public subscript(lenient i: Int) -> Value? {...}
I know there are limitations on what features are supported by bridging, but I didn't see either of these cases listed.
I don't want to mess with my Swift APIs just to get this bridging to work. Is there any way to annotate Swift declarations to suppress them from the generated C++ header?