Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Swift from C

I have seen many articles explaining how to call C functions from Swift, but I would like to explore the converse (if possible), to call Swift functions from C.

I have seen examples illustrating Swift functions in objC, but these do not get me any closer to my goal. Is this task even supported?

like image 472
sam Avatar asked Jun 11 '15 20:06

sam


1 Answers

The only supported way to call Swift code from C code is to use Objective-C between the two.

That's not to say that it's entirely impossible, but someone would have to come up with a NSInvocation-like utility and wrappers for objects that don't have an exact C representation.

like image 182
zneak Avatar answered Sep 25 '22 23:09

zneak