Skip to content

Instantly share code, notes, and snippets.

@BrunoMiguens
Created May 27, 2019 14:28
Show Gist options
  • Save BrunoMiguens/12c05039e5107b35944f94256b96db39 to your computer and use it in GitHub Desktop.
Save BrunoMiguens/12c05039e5107b35944f94256b96db39 to your computer and use it in GitHub Desktop.
[Medium] Swift: Using Javascript library - Load Library to JSContext
import JavaScriptCore
func loadJSBundle(for context: JSContext?) {
guard let libraryPath = Bundle.main.path(forResource: "cson-parser-bundle", ofType: "js"),
let libraryCode = try? String(contentsOfFile: libraryPath) else {
return
}
context?.evaluateScript(libraryCode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment