diff --git a/Source/SWXMLHash.swift b/Source/SWXMLHash.swift index 9acfdca5..231c19d5 100644 --- a/Source/SWXMLHash.swift +++ b/Source/SWXMLHash.swift @@ -425,9 +425,16 @@ class FullXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate { } func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) { +#if os(Linux) + if let err = parseError as? NSError { + parsingError = ParsingError(line: err.userInfo["NSXMLParserErrorLineNumber"] as? Int ?? 0, + column: err.userInfo["NSXMLParserErrorColumn"] as? Int ?? 0) + } +#else let err = parseError as NSError parsingError = ParsingError(line: err.userInfo["NSXMLParserErrorLineNumber"] as? Int ?? 0, column: err.userInfo["NSXMLParserErrorColumn"] as? Int ?? 0) +#endif } } diff --git a/Tests/SWXMLHashTests/XMLParsingTests.swift b/Tests/SWXMLHashTests/XMLParsingTests.swift index e4087423..49c20a87 100644 --- a/Tests/SWXMLHashTests/XMLParsingTests.swift +++ b/Tests/SWXMLHashTests/XMLParsingTests.swift @@ -320,9 +320,11 @@ class XMLParsingTests: XCTestCase { XCTAssertNotNil(err) +#if !os(Linux) if err != nil { XCTAssert(err!.line == 1) } +#endif } }