cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
MIT License
1.06k stars 151 forks source link

Build fails with xcode 9.3 (Beta) #77

Closed skathiresan closed 6 years ago

skathiresan commented 6 years ago

Description:

Building Fuzi with xcode 9.3 fails with error Redefinition of module 'libxml2' [ I think the issue is because of the file module.modulemap. The error should go way by renaming it to something else like Fuzi_module.modulemap.]

How to reproduce:

Just include Fuzi to a new project using cocoapods and try building with xcode 9.3 Sample -> Fuzi_xcode93.zip

nixzhu commented 6 years ago

Same issue with Xcode 9.3

nixzhu commented 6 years ago

Maybe it's the same as https://github.com/tid-kijyun/Kanna/issues/176

dan12411 commented 6 years ago

same issue as https://github.com/tid-kijyun/Kanna/pull/177, I temporary change the "libxml2" to "libxmlFuzi" locally, and build without error

banjun commented 6 years ago

I think the error is caused by Redefinition. Xcode 9.2 does not have the modulemap. Xcode 9.3 does have it. May simply removing repeated modulemap in Fuzi resolve this, instead of renaming it?

SuperY commented 6 years ago

@banjun Not work for me, you can try and PR.

ChaselAn commented 6 years ago

Use LiKui(https://github.com/ChaselAn/LiKui) to fix this problem

cezheng commented 6 years ago

Sorry folks I've been really busy lately and I'm thinking exactly what @banjun suggests. @SuperY what error did you get when you removed the modulemap?

xudafeng commented 6 years ago

@cezheng same error with xcode 9.3

lovexiaov commented 6 years ago

Hi @cezheng , When I renamed libxml2 to libxml2Fuzi, I got this error:

Undefined symbols for architecture arm64:
  "_xmlXPathRegisterNs", referenced from:
      Fuzi.XMLElement.(cXPath in _EFCFDABBC19A6AC171FF6706F1D8B4CC)(xpathString: Swift.String) -> Swift.UnsafeMutablePointer<__C._xmlXPathObject>? in Queryable.o
  "_xmlXPathEvalExpression", referenced from:
      Fuzi.XMLElement.(cXPath in _EFCFDABBC19A6AC171FF6706F1D8B4CC)(xpathString: Swift.String) -> Swift.UnsafeMutablePointer<__C._xmlXPathObject>? in Queryable.o
  "_xmlStrcasecmp", referenced from:
      closure #1 (Swift.UnsafePointer<Swift.Int8>) -> Swift.Bool in (extension in Fuzi):Swift.String.caseInsensitivelyEqual(to: Swift.UnsafePointer<Swift.UInt8>) -> Swift.Bool in Helpers.o
      closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> Swift.Bool in (extension in Fuzi):Swift.StaticString.caseInsensitivelyEqual(to: Swift.UnsafePointer<Swift.UInt8>) -> Swift.Bool in Helpers.o
  "_htmlReadMemory", referenced from:
      closure #1 (Swift.UnsafePointer<Swift.Int8>?, Swift.Int32, Swift.UnsafePointer<Swift.Int8>?, Swift.UnsafePointer<Swift.Int8>?, Swift.Int32) -> Swift.UnsafeMutablePointer<__C._xmlDoc>? in Fuzi.HTMLDocument.(in _A7587B54FC91508C310D7D9A9E31E8E2).init(cChars: [Swift.Int8], options: Swift.Int32) throws -> Fuzi.HTMLDocument in Document.o
  "_xmlFreeDoc", referenced from:
      Fuzi.XMLDocument.deinit in Document.o
  "_xmlReadMemory", referenced from:
      closure #1 (Swift.UnsafePointer<Swift.Int8>?, Swift.Int32, Swift.UnsafePointer<Swift.Int8>?, Swift.UnsafePointer<Swift.Int8>?, Swift.Int32) -> Swift.UnsafeMutablePointer<__C._xmlDoc>? in Fuzi.XMLDocument.(in _A7587B54FC91508C310D7D9A9E31E8E2).init(cChars: [Swift.Int8], options: Swift.Int32) throws -> Fuzi.XMLDocument in Document.o
  "_xmlXPathFreeContext", referenced from:
      Fuzi.XMLElement.(cXPath in _EFCFDABBC19A6AC171FF6706F1D8B4CC)(xpathString: Swift.String) -> Swift.UnsafeMutablePointer<__C._xmlXPathObject>? in Queryable.o
  "_xmlGetLastError", referenced from:
      static Fuzi.XMLError.lastError(defaultError: Fuzi.XMLError) -> Fuzi.XMLError in Error.o
  "_xmlGetLineNo", referenced from:
      closure #1 () -> Swift.Int in Fuzi.XMLNode.lineNumber.getter : Swift.Int in Node.o
  "_htmlNodeDump", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.rawXML.getter : Swift.String in Node.o
  "_xmlXPathFreeObject", referenced from:
      Fuzi.XPathNodeSet.deinit in NodeSet.o
      Fuzi.XPathFunctionResult.deinit in Queryable.o
  "_xmlBufferCreate", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.rawXML.getter : Swift.String in Node.o
  "_xmlBufferFree", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.rawXML.getter : Swift.String in Node.o
  "_xmlGetNsProp", referenced from:
      Fuzi.XMLElement.attr(Swift.String, namespace: Swift.String?) -> Swift.String? in Element.o
  "_xmlXPathNewContext", referenced from:
      Fuzi.XMLElement.(cXPath in _EFCFDABBC19A6AC171FF6706F1D8B4CC)(xpathString: Swift.String) -> Swift.UnsafeMutablePointer<__C._xmlXPathObject>? in Queryable.o
  "_xmlBufferContent", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.rawXML.getter : Swift.String in Node.o
  "_xmlResetLastError", referenced from:
      Fuzi.XMLDocument.(in _A7587B54FC91508C310D7D9A9E31E8E2).init(parseFunction: (Swift.UnsafePointer<Swift.Int8>?, Swift.Int32, Swift.UnsafePointer<Swift.Int8>?, Swift.UnsafePointer<Swift.Int8>?, Swift.Int32) -> Swift.UnsafeMutablePointer<__C._xmlDoc>?, cChars: [Swift.Int8], options: Swift.Int32) throws -> Fuzi.XMLDocument in Document.o
  "_xmlGetProp", referenced from:
      Fuzi.XMLElement.attr(Swift.String, namespace: Swift.String?) -> Swift.String? in Element.o
  "_xmlDocGetRootElement", referenced from:
      Fuzi.XMLDocument.(in _A7587B54FC91508C310D7D9A9E31E8E2).init(cDocument: Swift.UnsafeMutablePointer<__C._xmlDoc>) -> Fuzi.XMLDocument in Document.o
  "_xmlNodeGetContent", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.stringValue.getter : Swift.String in Node.o
  "_xmlNodeDump", referenced from:
      closure #1 () -> Swift.String in Fuzi.XMLNode.rawXML.getter : Swift.String in Node.o
  "_xmlResetError", referenced from:
      static Fuzi.XMLError.lastError(defaultError: Fuzi.XMLError) -> Fuzi.XMLError in Error.o
  "_xmlFree", referenced from:
      Fuzi.XMLElement.attr(Swift.String, namespace: Swift.String?) -> Swift.String? in Element.o
      closure #1 () -> Swift.String in Fuzi.XMLNode.stringValue.getter : Swift.String in Node.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could you help me to solve this problem?

banjun commented 6 years ago

I have removed the modulemap in #83. Feedbacks are helpful, @cezheng & folks here!

@lovexiaov Undefined symbols is caused by missing -lxml2. We should eventually link with libxml2 in any way.

SuperY commented 6 years ago

@banjun You are right. Need add '-lxml2' to Linker Flags. @cezheng It's time to merge....

lovexiaov commented 6 years ago

@banjun @SuperY Thanks, add -lxml2 to Linker Flags solved my problem.

-lxml2