sam
sam

Reputation: 516

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?

Upvotes: 8

Views: 853

Answers (1)

zneak
zneak

Reputation: 138251

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.

Upvotes: 3

Related Questions