Swift Framework with libxml

风格不统一 提交于 2019-11-30 13:51:49

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

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 *
}

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

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.

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

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.

javaing

in xcode6, iphone8.3, the path will be

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk/usr/include/libxml2

*update: a more easy way: $(SDKROOT)/usr/include/libxml2
thank to: iPhone libxml2 not found during build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!