Passing swift structure to c function

How can i declare c structure in swift and pass same structure pointer
to the c function using swift 5 ?

There’s currently no way to declare a struct in Swift that’s guaranteed to follow C layout conventions. If you want to share a struct between Swift and C, you have to declare the struct in C and then import it into Swift.

Doing this sharing in app code is simple (use a bridging header) but it seems that won’t work for you:

I am creating SPM Package

Check out this thread, which has a suggestion for how to do this in an SPM package.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like