How to use c++ function that returns std::string

I'm trying out the new c++ interoperability, but having trouble working with a c++ function that returns an std::string, is that possible? A function that returns an int is fine but as soon as I try to include in the header of a c++ file I get an error saying the file is not found.

For example this function I cannot get to work in swift:

std::string test() {
    return "test";
}

My header file would look like:

#include <string>
std::string test();

I am using the latest beta of xcode with the -cxx-interoperability-mode=default flag.

You might be jumping the gun. :slight_smile:

You're saying this is not possible yet?

This is supported and should be working fine.
Could you please share the exact error message that you are getting?

Turns out that in my build settings for my library, I still had objective-c as a supported language in addition to objective-c++. Only keeping the latter resolved my problem :).

1 Like

Awesome, thanks for sharing!