Skip to content

Instantly share code, notes, and snippets.

@russbishop
Created June 19, 2015 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russbishop/bdcd22e277fa957162d5 to your computer and use it in GitHub Desktop.
Save russbishop/bdcd22e277fa957162d5 to your computer and use it in GitHub Desktop.
dylib from Swift
typealias verFunc = @convention(c) ()->UnsafePointer<CChar>
let libz = dlopen("libz.dylib", RTLD_LAZY)
let ret = dlsym(libz, "zlibVersion")
let zLibVersion = unsafeBitCast(ret, verFunc.self)
print("\(String.fromCString(zLibVersion())!)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment