cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails with xcode 9.3 (Beta)

skathiresan opened this issue · comments

commented

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.]

  • Expected behaviour:
    Successful Build without errors.

  • Actual behaviour:
    Build Failure.

Environment

  • Package Manager:

    • Carthage, version:
    • CocoaPods, version:1.4
    • Manually
  • Fuzi version: Latest (2.0.1)

  • Xcode version: 9.3

How to reproduce:

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

Same issue with Xcode 9.3

Maybe it's the same as tid-kijyun/Kanna#176

same issue as tid-kijyun/Kanna#177, I temporary change the "libxml2" to "libxmlFuzi" locally, and build without error

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?

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

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

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?

@cezheng same error with xcode 9.3

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?

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.

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

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