zneak
zneak

Reputation: 138251

Invoking Swift code from C

How do I call Swift code from C or C++? I can only find documentation for the other way around.

If all else fails, I'll wrap my code in an Objective-C class and use it for interop, but I was wondering if there would be another way.

Upvotes: 1

Views: 330

Answers (1)

jtbandes
jtbandes

Reputation: 118761

Xcode automatically generates a "<yourmodule>-Swift.h" header, which you can simply import from your Obj-C code (it has to be Obj-C, since Swift classes are exported as Obj-C classes). See Importing Swift into Objective-C.

Upvotes: 2

Related Questions