C++ interoperability and Swift Optional

I have the following code snippet:

import Foundation

public class X {

}

public class Test {
    public var inner: X?

}

When enabling C++ interoperability and importing generated -Swift.h header, I get the following errors:

  • "Out-of-line definition of 'setInner' does not match any declaration in 'CppExportedCrash::Test'"
  • "Use of undeclared identifier 'X'"

My understanding is that Swift Optional should be supported, but maybe I am missing something here?

Doesn't work without Optionals either:

public class X {}

public class Test {
    public var inner = X()
}
1 Like