CoreOffice / XMLCoder

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

Enum decoding fails #269

Closed Matze2010 closed 11 months ago

Matze2010 commented 11 months ago

I try to decode the following XML:

<D:lockentry xmlns:D="DAV:">
  <D:lockscope>
    <D:exclusive/>
  </D:lockscope>
  <D:locktype>
    <D:write/>
  </D:locktype>
</D:lockentry>

into the following Struct (shouldProcessNamespaces = true):

struct LockEntry: Codable {

   enum LockScope: Codable {
      case exclusive
      case shared
   }

   var lockscope: LockScope
}

However, it fails with the following error:

Value at path 'lockscope' was not of type 'Dictionary<String, Any>'. Expected to decode Dictionary<String, Any> but found SingleKeyedBox instead.


I have no idea what I'm missing or getting wrong. Any help would be appreciated.

Matze2010 commented 11 months ago

I found the source of the problem. For some reason Swift Package Manager downloads the 0.17.0 release and not the current 0.17.1 release. Adding the dependency .package(url: "https://github.com/CoreOffice/XMLCoder.git", revision: "b1e944c") to Package.swift resolves the issue for me.

So it remains unclear, why SPM does not use the most current release version.