Bridge Swift到Objective-C库“ono”使用cocoapods

问题描述:

对于我的swift iPhone应用程序,我需要解析XML。

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

我正在使用 Alamofire 并尝试使用 Ono 这是一个客观的c库。我用cocoapods来安装Alamofire& Ono。

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

我已按照此处的步骤操作:如何将Cocoapods与Swift项目集成?

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

我有 #import<我的桥接标题中的Ono / Ono.h>

很奇怪,在swift中我可以引用许多Ono类,但是有一个函数 XMLDocumentWithData 我不能。例如。 HTMLDocumentWithString 我可以调用,但 XMLDocumentWithData 我不能。

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.

正如mattt在他的评论中指出的那样,代码生成不知何故已哄骗货物。

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)