NSArray element failed to match the Swift Array Element type Expected

Hi,

I've searched the internet regarding this problem, but mine seems to be much special. I'm trying to parse a HTML document using queryselector as follow:

let doc = HTMLDocument(string: str)
      let elements = doc.querySelectorAll("script")
      elements.forEach { ddElement in
        if(ddElement.elementId == "js-competition"){
          scr = ddElement.textContent

and on elements.forEach line I receive the following error:

Precondition failed: NSArray element failed to match the Swift Array Element type Expected HTMLElement but found HTMLElement

The fact that the expected type is the same with the found one, it's very weird. Everything was working fine, until I renamed the project's name, and some updates for conversion to swift 5 were triggered. The build is for iOS 15.2.

Did you face issues like this before? Because for me it looks like a xCode bug.

Thank you!

NSArray element failed to match the Swift Array Element type Expected
 
 
Q