Highlightr icon indicating copy to clipboard operation
Highlightr copied to clipboard

'undefined' on real device with iOS 16, while working on iOS 18 simulator

Open JaDenis opened this issue 1 year ago • 5 comments

Have anyone encountered 'undefined' error? It works fine in simulator, but on device I get 'undefined' Please help, I'm trying to debug in the meantime: latest suspicion is JavaScriptCore on iOS 16 is incpompatible with highlightr.js code

if let highlightr = Highlightr() {
    highlightr.setTheme(to: "dark")
    let code = "import UIKit"
    // You can omit the second parameter to use automatic language detection.
    let highlightedCode = highlightr.highlight(code)
    self.textView.attributedText = highlightedCode
}

JaDenis avatar Dec 17 '24 07:12 JaDenis

I also encountered this issue. Have you solved it?

Tang-Hai avatar Dec 18 '24 12:12 Tang-Hai

Not only iOS 16. iOS 15 crash on supportedLanguages

Image

    open func supportedLanguages() -> [String] {
        let res = hljs.invokeMethod("listLanguages", withArguments: []) // return undefined
        return res!.toArray() as! [String]
    }

But I solved it by updating highlightjs to the latest release.

zeroskylian avatar Apr 07 '25 07:04 zeroskylian

@raspu

LiYanan2004 avatar Apr 08 '25 13:04 LiYanan2004

Not only iOS 16. iOS 15 crash on supportedLanguages

Image

open func supportedLanguages() -> [String] {
    let res = hljs.invokeMethod("listLanguages", withArguments: []) // return undefined
    return res!.toArray() as! [String]
}

But I solved it by updating highlightjs to the latest release.

@zeroskylian Could you maybe make a PR with the updated lib? I don't have enough time to maintain this lib, so I would appreciate people's help here.

raspu avatar Apr 08 '25 14:04 raspu

Not only iOS 16. iOS 15 crash on supportedLanguages Image

open func supportedLanguages() -> [String] {
    let res = hljs.invokeMethod("listLanguages", withArguments: []) // return undefined
    return res!.toArray() as! [String]
}

But I solved it by updating highlightjs to the latest release.

@zeroskylian Could you maybe make a PR with the updated lib? I don't have enough time to maintain this lib, so I would appreciate people's help here.

PR has been submitted

zeroskylian avatar Apr 09 '25 02:04 zeroskylian