How can i convert @convention to a escaping closure

i want to write ios plugin for unity.
for that i need to communicate between c# <-> c <-> swift.
i have following method:

public func AwesomeSDK_initializeSDK(_ name: UnsafePointer<CChar>?,
                          _ apiKey: UnsafePointer<CChar>?,
                                     _ completionHandler: @convention(c) (UnsafePointer<CBool>) -> Void) 

i want to convert last parameter into escaping closure in swift.

@_cdecl("AwesomeSDK_initializeSDK")
public func AwesomeSDK_initializeSDK(_ name: UnsafePointer<CChar>?,
                          _ apiKey: UnsafePointer<CChar>?,
                                     _ completionHandler: @convention(c) (UnsafePointer<CBool>) -> Void) {
    Awesome.initializeSDK(name: String(cString: name!),
                          apiKey: String(cString: apiKey!),
                          completionHandler: <convert_@convention_to_escaping_closure_here>)
}

1 Like

Make a closure that calls it.