Swift and C++ interoperability workgroup announcement

This is great news. C++ interop is a huge benefit for some of us. I don't do this now but I remember I had to wrap C++ code into Objective C wrapper classes which was quite messy.

Please clarify no this. I can now use Obj-C in otherwise swift app on iOS, will I lose this ability? Or do you mean, depending upon some compiler switch I'd be able to use either Obj-C interop or C++ interop but not both? Is this going to be addresses in the future?

How std::string interop will work in practice? For example I have SwiftUI or UIKit app that wants Swift.String, and it can tolerate NSString (as NSString is bridged to Swift.String reasonably well). And I'll do the model layer in C++ with std::string, will I need to recreate String from std::string to show it in UI or not?

(I remember there was a dodgy CFStringCreateWithCStringNoCopy -> NSString -> String route for those who are brave but that's a last resort and when I tested it it only had the "no copy" behaviour for certain encodings).

1 Like