Created
May 27, 2019 14:28
-
-
Save BrunoMiguens/12c05039e5107b35944f94256b96db39 to your computer and use it in GitHub Desktop.
[Medium] Swift: Using Javascript library - Load Library to JSContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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