iPhone libxml2 not found during build

跟風遠走 提交于 2019-11-30 13:56:07

问题


I currently got some errors with libxml2 in my iPhone project. This was working before, after making some changes in my build properties building failed. (libxml2.dylib is added in the build phases)

#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/xmlstring.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>

I've added the following items to the Build Settings:

Other Linker Flags: -lxml2
Header Search Paths: /usr/include/libxml2

I've tried adding them to the project and targets (at the same time, and switching between them) without any difference.

I also tried adding the following to the Header Search Path:

${SDKROOT}
${SDK_DIR}

Both with no result.

Building fails for: iPhone device iPhone and iPad emulator

Anyone have an idea?

I'm using the GData Objective-C client library: http://code.google.com/p/gdata-objectivec-client/ I'm compiling the source files directly into my project and followed all the steps that are given in the wiki. When manually importing the libxml headers again, XCode suggests the following:

#import <libxml2/libxml/tree.h>

Which doesn't work either.


回答1:


Add ${SDKROOT}/usr/include/libxml2 as a header search path instead of only ${SDKROOT}.

Watch out that you all build targets that need libxml get the extra search path. If you add the path to your project's build settings, all its targets will inherit it and there shouldn't be a problem.




回答2:


  • Add libxml2.dylib in Build Phases.
  • Add TFHpple.m, TFHppleElement.m, XpathQuery.m to Build Phases (Compile Sources).
  • Add
    Other Linker Flags: -lxml2 
    Header Search Paths: ${SDK_DIR}/usr/include/libxml2

in PROJECT --> Build Phases and in TARGETS --> Build Phases.



来源:https://stackoverflow.com/questions/6173766/iphone-libxml2-not-found-during-build

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