See if we there is a better way to deal with JavaScript instead of sending raw strings to the web view.
For example using JavaScritpCore:
lazy var context: JSContext? = {
let context = JSContext()
guard let
commonJSPath = Bundle.main.path(forResource: "opensheetmusicdisplay.min", ofType: "js") else {
print("Unable to read resource files.")
return nil
}
do {
let common = try String(contentsOfFile: commonJSPath, encoding: String.Encoding.utf8)
_ = context?.evaluateScript(common)
} catch {
print("Error while processing script file: \(error)")
}
return context
}()
override func viewDidLoad() {
super.viewDidLoad()
guard let context = context else {
print("JSContext not found.")
return
}
}
See if we there is a better way to deal with JavaScript instead of sending raw strings to the web view.
For example using JavaScritpCore: