带有libxml的Swift框架 [英] Swift Framework with libxml

查看:121
本文介绍了带有libxml的Swift框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用KissXML Objective-C库的Swift Framework项目. KissXML在内部使用libxml.

I have Swift Framework project that uses the KissXML Objective-C library. KissXML internally uses libxml.

当我构建xcode项目(Xcode 6-beta 5)时,出现此错误:

When I build the xcode project (Xcode 6 - beta 5), I get this error:

error: <unknown>:0: error: '/SwiftFramework/SwiftFramework/KissXML/DDXMLNode.h:2: include of non-modular header inside framework module SwiftFramework.DDXMLNode

我已经看到了答案公开相关的头文件.我已经做到了,但是我不确定如何解决在DDXMLNode.h中导入的此标头的情况,而该标头显然不是我的项目的一部分:

I have seen this answer that discusses making the relevant header files public. I have done that but I am not sure how to address the case of this header that is imported in the DDXMLNode.h and that is not explicitly part of my project:

#import <libxml/tree.h>

关于如何处理此问题的任何建议?

Any suggestions on how to handle this?

注意:我已经在仅Objective-C的项目上使用了KissXML,并且效果很好(Xcode 5).

Note: I have used KissXML on a Objective-C only project and it worked fine (Xcode 5).

推荐答案

诀窍是创建一个模块并将其包含在您的项目中.

The trick is to create a module and include it on your project.

要创建模块,请创建一个名为 module.modulemap 的文件,该文件将API导出到感兴趣的头文件中,如下所示:

To create the module you create a file named, let's say, module.modulemap which exports the API on the header files of interest like this:

module libxmlModuleDevice {
    header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h"
    export *
}

module libxmlModuleSimulator {
    header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/libxml2/libxml/tree.h"
    export *
}

请注意,您需要对模拟器和实际设备都执行此操作-因此文件上的2个条目.

Notice that you need to do this both for the simulator and for the actual device - hence the 2 entries on the file.

此文件 module.modulemap 可以放置在任何地方.我在与Xcode的项目文件(.xcodeproj)相同的级别上创建了一个名为 modules 的目录,并将 module.modulemap 文件放置在此处.

This file module.modulemap can be placed anywhere. I created a directory called modules at the same level as the Xcode's project file (.xcodeproj) and placed the module.modulemap file there.

然后将包含此文件的目录添加到Xcode项目的 Build Settings 下的 Header Search Path 中.

Then add directory that contains this file to the Header Search Path under Build Settings of you Xcode project.

在此示例中,您要做的就是将单词 modules 添加到 Header Search Path 中,因为 modules 目录位于与Xcode项目文件处于同一级别.这将在内部更新Xcode项目变量 HEADER_SEARCH_PATHS .就是这样.

In this example all you have to do is to add the word modules to the Header Search Path because the modules directory is at the same level as the Xcode project file. This will update internally the Xcode project variable HEADER_SEARCH_PATHS. That's it.

这篇关于带有libxml的Swift框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆