I try to use this new language to start a new project with Some of my old code, I used Libxml2.2 in my old project,so xcode shows "libxml.h/parse.h file not found" after my putting the code in my new project. i have already imported the "libxml2.2.dylib"
4 Answers
I 've made it work with CommonCrypto https://github.com/onmyway133/CommonCrypto.swift but libxml should be the same. Things to keep in mind
module.modulemap
Read http://clang.llvm.org/docs/Modules.html#module-map-language
Create a folder named libxml2 (in my case, it is at the same directory as my project file), then create a module.modulemap file inside
module libxml2 { header "/usr/include/libxml2/libxml/tree.h" export * } Here I add just tree.h, but you can add more for your need
SWIFT_INCLUDE_PATHS
Go to Target Build Settings, add this into Import Paths
${SRCROOT}/libxml2 HEADER_SEARCH_PATHS
Read Why am I getting this "libxml/tree.h file not found" error?
Go to Target Build Settings, add this into Header Search Paths
$(SDKROOT)/usr/include/libxml2 Interesting related posts
Comments
To get this working with my project in Xcode 6, I navigated to "Build Settings" for my project, and selected my target. I then searched for "Header Search Paths" in the Build Settings, and added the following line to both debug and release:
$(SDKROOT)/usr/include/libxml2 2 Comments
You will have to create a custom module map file containing the header of libxml/tree.h like so :
module libxml [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h" export * } Then you place this file (module.modulemap) inside a folder -module for example- and add it to your project's and target's build settings.
You can now use @import libxml; in your code.