Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: "Include of non-modular header" with libxml

I'm trying to build my own framework 'VBL' that uses TouchXML which is based on libxml.dylib

The framework is building fine, but whenever I'm trying to use it in any project, I got the following error:

"Include of non-modular header inside framework module VBL.CXMLNode"

And that's specifically because in header CXMLNode.h inside my framework, I have to include libxml as follows:

#include <libxml/tree.h>

Is it safe to set the following property inside Build Settings to YES?

allow non-modular included in framework modules

But this will not work with Swift anyways, so any other suggestions?

like image 788
Mohamed Salem Avatar asked Apr 25 '15 12:04

Mohamed Salem


1 Answers

You can try to hide the #include <libxml/tree.h> in a private header or in the .m file if you can.

You can also try to create a module.modulemap file with the libxml root header inside to fool the swift compiler:

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

Then place the file inside a folder, -module/module.modulemap- for example.

Once you did that you should link it in import paths within the swift compiler search path section of the target build setting, and to the target's header search path :

$(SRCROOT)/module

Then in your code, you can use @import libxml;

like image 89
Loegic Avatar answered Nov 16 '22 01:11

Loegic