Trying to understand Swift-C++ interopability

Hi,

I'm struggling to understand using Swift-C++ in the same project. I have an existing code-base that makes heavy use of Swift-Objective-C interoperability.

We make use of swift classes in our project. When I enable swift-objective c interoperability I am running into numerous build errors in the generated bridging header.

I'm trying to understand why these errors exist and what to do to get around them. I have a project that I've set up with some test code, and I'm running into an error here:

public class Foo {
    let name: String
    public init(name: String) {
        self.name = name
    }
}

public class Bar {
    let name: String

    public init(name : String) {
        self.name = name;
    }
    
    public func getFoo() -> Foo {
        return Foo(name: self.name);
    }
}

In the header file:

Unknown type name 'Foo'

SWIFT_INLINE_THUNK Foo getFoo() SWIFT_SYMBOL("s:13ForestBuilder3BarC6getFooAA0E0CyF");

This error goes away if I use structs, but for the purposes of porting my codebase, I'd prefer to use classes. Do classes not play nice here? Or am I misunderstanding something.

Thanks.

Trying to understand Swift-C++ interopability
 
 
Q