Building Swift Bindings to libgit2
The
strparameter is of typeUnsafePointer<Int8>, but thanks to Swift’s ability to interoperate with C, we can just pass this function a SwiftString. Read the Apple blog article linked above for details.[…]
Unfortunately, in Interacting with C Pointers in Swift, @develtima explains that we can’t get a usable
CFunctionPointerto a function defined in Swift.So instead, Gift defines Objective-C helper functions that take a Swift closure, and execute that closure from within a C callback function.