Bridge Swift to Objective-C library “ono” using co

2019-05-29 05:59发布

问题:

For my swift iPhone app I'm needing to parse XML.

I'm using Alamofire and trying to use Ono which is an objective c library. I used cocoapods to install Alamofire & Ono.

I've followed the steps here: How to integrate Cocoapods with a Swift project?

where I have #import <Ono/Ono.h> in my bridging header.

Whats very odd is that in swift I can reference many of the Ono classes, but there is one function XMLDocumentWithData that I can't. E.g. HTMLDocumentWithString I can call, but XMLDocumentWithData I can't.

回答1:

As mattt points out in his comment, somehow the code generation has "slurped" up the goods.

Below is how you can call the method instead for now:

let XML = ONOXMLDocument(data: data, error: &XMLSerializationError)
//let XML = ONOXMLDocument.XMLDocumentWithData(data, error: &XMLSerializationError)