4

As far as I understand currently with XCode 7.3 and Swift 2.2 there is no elegant way to create a project with C++ and Swift without introducing Objective C

Can I mix Swift with C++? Like the Objective - C .mm files

I remember seeing somewhere that it was a goal of Apple to provide a solution to do away with this requirement.

I have been going through some of the WWDC2016 sessions but have yet to see this mentioned.

Has anyone come across any mention of a change in Xcode or in Swift, which will simplify C++ handling.

I am asking for a link to a session or discussion where this has been discussed.

I am not sure of the scope of any NDA when answering this question but I imagine posting a link will be safe enough

Community
  • 1
  • 1
Ryan Heitner
  • 13,119
  • 6
  • 77
  • 119
  • You still cannot bridge directly to C++ from Swift. You must wrap your C++ in Objective-C or use Objective-C++. I was at WWDC and there was no news about C++ interoperability with Swift. I'm torn if this question should be closed as a duplicate of the question you linked to, since it is asking the same question, albeit with different tool versions. – JAL Jun 20 '16 at 12:59
  • It is a duplicate , but we were promised new solutions (even though I cannot remember where) It has never been clear to me the procedure for asking a duplicate question once the answer may have changed., because of new versions – Ryan Heitner Jun 20 '16 at 13:04
  • As provided by simpleBob SE-0038 is a proposal which is not yet implemented in package manager which will allow the package manager to include C family of languages – Ryan Heitner Jun 20 '16 at 13:11
  • Right. If anything, that should be a comment or an answer on the linked question as well. – JAL Jun 20 '16 at 13:17
  • I will add a link to the question to SE-0038 and set up a Google alert, at least I have a name for this issue. You are welcome to close this as duplicate – Ryan Heitner Jun 20 '16 at 13:19

1 Answers1

1

You can see the next changes here.

But I don't think it will ever get easier as importing an ObjectiveC++ package. Since, unlike ObjectiveC++, Swift isn't a superset of C++

Daniel
  • 20,420
  • 10
  • 92
  • 149
  • Here is a reference to what I was looking for from your link .https://github.com/apple/swift-evolution/blob/master/proposals/0038-swiftpm-c-language-targets.md It is under the Accepted proposals which do not have a complete implementation – Ryan Heitner Jun 20 '16 at 13:08
  • @RyanHeitner That link talks about adding support for "foreign" packages to the package manager, not about interoperation between the languages. – molbdnilo Jun 20 '16 at 14:18
  • @molbdnilo my understanding was that if you have a "foreign package" it implies that there must be a way of talking to it. – Ryan Heitner Jun 21 '16 at 08:22
  • 2
    @RyanHeitner Quoting from [the discussion](http://thread.gmane.org/gmane.comp.lang.swift.evolution/7293): "This proposal is not about mixed Swift-C++ code. It's about allowing a Swift package to depend on and build a pure C/C++ module." – molbdnilo Jun 21 '16 at 08:31
  • @molbdnilo Good spot !, I guess I will have to wait and see if they implement another proposal to help out. – Ryan Heitner Jun 21 '16 at 08:37
  • Is there any news on which version of c++ I should expect in xcode 8? It's always a tense moment when upgrading xcode. Apple don't seem to understand the idea of backward compatibility. – Richard Hodges Sep 14 '16 at 12:51