Swift and C++ interoperability workgroup announcement

Ah, I see the misunderstanding.

I think some good terminology (that we can bike shed) is: Forward Interop for Swift consuming C++ APIs, Reverse/Backwards Interop for C++ consuming Swift APIs, and Bidirectional Interop when talking about both. (Because, when you're moving to Swift, you're moving forward :grin:)

6 Likes

IMO that would be harder to remember and no easier to say/write than simply "importing C++ [into Swift]" and "importing Swift [into C++]." Where the bracketed parts are optional in this context.

But that doesn't cover everything because you have two kinds of bridging for each kind of import. Calling a C++ function auto f(A) -> B from Swift involves bridging in both directions. I suggest

  • Importing Swift [into C++]
  • Importing C++ [into Swift]
  • Bridging Swift T [to C++ U]
  • Bridging C++ T [to Swift U]

Is there anything else we need to cover?

4 Likes

I would love to be involved, as we're also working on Swift interoperability with our own compiler right now.

2 Likes

This is extraordinarily ambitious, and I'm excited for it! Thank you!

1 Like

It’s been exciting seeing this effort take form! I’d like to be a part of the workgroup.

2 Likes

^ Same. This is great and I love what this could mean. Being able to directly interface with the swift standard library is a must-have and this achieves that so perfectly. Yes, I would love to be in the workgroup.

1 Like

C++ interop has been implemented by extending the existing ClangImporter so far, hasn't it?
However, the current ClangImporter has potentially bugs because it is designed as a singleton.
I hope there would be some plans to split it into several classes to reduce such bugs, since there is an abstract class named ClangModuleLoader.

Hello,
I am happy to see this announcement and would like to join the workgroup and contribute as much as I can.

1 Like

I cannot open the link to the cpp manifesto https://github.com/apple/swift/blob/main/docs/CppInteroperabilityManifesto.md.
Is the link relocated? Or is the group disbanded?

The link is relocated

2 Likes

Hi there, I'm Riccardo, nice to meet you all.

I work at Meta in the React Native team and we are pretty interested in the Swift/C++ interop. From here I can see that the project is progressing and it is in a good spot.

I'd like to contribute to the project and I wanted to ask a few questions:

  • Does the project have an ETA for when it would be officially released, out of the experimental stage?
  • Is there anything we can do to help developing it further and move toward a production-ready state?

Thanks for the amazing work you already did,

Riccardo.

8 Likes

Riccardo, we (myself, Daniel Rodriguez and others) are actively working on C++-Interop at Meta ; we are always looking for more folks to work with on our end :slight_smile:. Issues are tagged here (I have filed a few):

Use the "C++-Interop" label manually. The Discourse Forums seems to reformat the URL and break the link when I paste it here.

3 Likes

Hi Riccardo, it's nice to meet you.

I'd like to contribute to the project and I wanted to ask a few questions:

Awesome! I will add you to the workgroup.

Does the project have an ETA for when it would be officially released, out of the experimental stage?

Not at the moment.

Is there anything we can do to help developing it further and move toward a production-ready state?

Absolutely! Before we dive into details to see what you could help with, it would be helpful to understand which use case you are most interested in, using Swift APIs from C++, or using C++ APIs from Swift, or both?

1 Like

Hi Alex_L, thanks for the reply.

Absolutely! Before we dive into details to see what you could help with, it would be helpful to understand which use case you are most interested in, using Swift APIs from C++, or using C++ APIs from Swift, or both?

I think that it will be both ways, actually. We have the engine written in C++ and it is now invoked by Java/Kotlin on Android and Objective-C++ on iOS. The engine can also invokes some delegates from the application code, so it could have to import some Swift files.
However, I believe that most of the interactions will require Swift to import some C++.

5 Likes

Great, that sounds good. There are definitely things we would appreciate help with on the forward side (using C++ from Swift), including helping with implementation, design, and also testing and adoption of features. It would definitely be good to get a new perspective from another adopter to see what the adoption experience is like, so that's probably the area you could help with the most.

1 Like

QQ: Do we have some timeline/roadmap for C++ interop?

You might enjoy this PR adding a roadmap to the Swift repository: https://github.com/apple/swift/pull/60501 though @zoecarver or others can probably comment more about its status.

9 Likes

Sorry I didn't notice this PR!

This is great!
Thanks for your hard work!

2 Likes