Hello!
I am importing libpostal
, a C library which defines a function called libpostal_parse_address
. When imported in Swift, this function has the following signature:
func libpostal_parse_address(_ address: UnsafeMutablePointer<Int8>!,
_ options: libpostal_address_parser_options_t) → UnsafeMutablePointer<libpostal_address_parser_response_t>!
The address
parameter is a char *
in C and imports as a UnsafeMutablePointer<Int8>!
—as expected. However, when I try and call this function passing a String
for the address
parameter, I receive an error:
let res = libpostal_parse_address("some string", options)
Error: "Cannot convert value of type 'String' to expected argument type 'UnsafeMutablePointer?'"
Is String
no longer directly convertible to UnsafeMutablePointer<Int8>!
? Thanks!