This issue just came up as I updated to Xcode 8 and Swift 3. After I opted to have the Swift 2 code to be transposed to Swift 3 this issue arose in the parse library I had previously imported(Kanna).
internal init(docPtr: xmlDocPtr, object: xmlXPathObject) {
switch object.type {
case XPATH_NODESET:
let nodeSet = object.nodesetval
if nodeSet == nil || nodeSet?.pointee.nodeNr == 0 || nodeSet?.pointee.nodeTab == nil {
self = .none
return
}
var nodes : [XMLElement] = []
let size = Int((nodeSet?.pointee.nodeNr)!)
for i in 0 ..< size {
let node: xmlNodePtr = nodeSet!.pointee.nodeTab[i]!
let htmlNode = libxmlHTMLNode(docPtr: docPtr, node: node)
nodes.append(htmlNode)
}
self = .NodeSet(nodeset: XMLNodeSet(nodes: nodes))
return
case XPATH_BOOLEAN:
self = .Bool(bool: object.boolval != 0)
return
case XPATH_NUMBER:
self = .Number(num: object.floatval)
case XPATH_STRING:
self = .String(text: Swift.String(cString: UnsafePointer<CChar>(object.stringval)) ?? "")
return
default:
self = .none
return
}
}
This code is an internal init within an extension in the Kanna.swift file. The error happens specifically in here:
self = .String(text: Swift.String(cString: UnsafePointer<CChar>(object.stringval)) ?? "")
The error message is:
'init' is unavailable: use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type.
Thanks a lot for the help!