Use C library in Swift

Someone has suggest about use C library in Swift.
when I attempt to use ImageMagick C library in Swift, I had to process some type translation between swift and the wrapper.
eg. the ImageMagick first example, look at here core.c
below is my swift code, not completed, how to assign value to the image_info.filename? so confuse :cry:

let executionPath = CommandLine.arguments[0]
MagickCoreGenesis(executionPath, MagickTrue)
let exception=AcquireExceptionInfo()
var image_info = ImageInfo()
let filePath = "/Users/wangbinbin/git/ImageMagickSwiftFoo/logo.gif"
let filePathB = filePath.withCString({$0})
for i in 0..<filePath.count {
    image_info.filename.1 = filePathB.advanced(by: i).pointee

the filename is a long tuple??? god

This thread may be helpful (but also maybe not):

thanks, very helpful.

Terms of Service

Privacy Policy

Cookie Policy