CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
797 stars 109 forks source link

Undefined symbols fails build #272

Closed FezVrasta closed 1 year ago

FezVrasta commented 1 year ago

Hi, I'm new to Swift and I'm trying to parse a XML file with XMLCoder. I installed the package using the built-in package manager of XCode and tried to use your package but at build time I get:

ld: Undefined symbols:
  XMLCoder.XMLDecoder.__allocating_init(trimValueWhitespaces: Swift.Bool, removeWhitespaceElements: Swift.Bool) -> XMLCoder.XMLDecoder, referenced from:
      Avalanche_ReportExtension.downloadReport() -> () in Avalanche_Report.o
  type metadata accessor for XMLCoder.XMLDecoder, referenced from:
      Avalanche_ReportExtension.downloadReport() -> () in Avalanche_Report.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm using the sample code provided by this repo:

let sourceXML = """
<note>
    <to>Bob</to>
    <from>Jane</from>
    <heading>Reminder</heading>
    <body>Don't forget to use XMLCoder!</body>
</note>
"""

struct Note: Codable {
    let to: String
    let from: String
    let heading: String
    let body: String
}

let note = try! XMLDecoder().decode(Note.self, from: Data(sourceXML.utf8))

let encodedXML = try! XMLEncoder().encode(note, withRootKey: "note")

Could someone please help me fix the issue?

FezVrasta commented 1 year ago

Clearing the build cache fixed the issue.