raspu / Highlightr

iOS & OSX Syntax Highlighter.
MIT License
1.66k stars 261 forks source link

Build error in HTMLUtils.swift #83

Closed brendand closed 3 months ago

brendand commented 3 years ago

I'm trying to build my app with the latest Xcode 12.5 beta 3 and I'm getting a build error due to this code in HTMLUtils.swift

 class func decodeNumeric(_ string : String, base : Int32) -> Character? {
        let code = UInt32(strtoul(string, nil, base))
        return Character(UnicodeScalar(code)!)
    }

I believe it's from the stroul() call.

The error is:

Undefined symbols for architecture arm64:
  "Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from:
      generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) 
-> Swift.ContiguousArray<A.Element> in HTMLUtils.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Does anyone have a solution for this or know a workaround?

brendand commented 3 years ago

Looks like this should solve it:

class func decodeNumeric(_ string : String, base : Int32) -> Character? {
   if let code = UInt32(string, radix: Int(base)) {
    return Character(UnicodeScalar(code)!)
   } else {
    return nil
   }
}
mateogianolio commented 3 years ago

How did you find out it was from the strtoul() call?

brendand commented 3 years ago

Trial and error commenting out code. Then some Googling which lead me to the above solution.