ios - Importing JavaScript file into Swift file -


i trying execute javascript sdk within swift application. unable find file however. added file project using cmd + click project -> add files "projectname" -> add file , move projectname/ folder.

i still unable file , run inside jscontext.

where going wrong?

here code (isok used test case):

import foundation import javascriptcore  public class wrapper {     public var isok: bool     var jscontext: jscontext      init (pathtosdk: string) {         let virtualmachine = jsvirtualmachine()         self.jscontext = jscontext(virtualmachine: virtualmachine)          if let sdkbundle = bundle.main.path(forresource: pathtosdk, oftype: "js") {             let bundlestring = try! string(contentsoffile: sdkbundle)             self.jscontext.evaluatescript(bundlestring)             print("successfully initialised javascript context")             self.isok = true         } else {             print("unable fetch sdk bundle @ path: \(pathtosdk)")             self.isok = false         }     } } 

i call in test:

func testisok() {     let wrapper = wrapper(pathtosdk: "sdk").isok     xctassertequal(wrapper, true) } 

and folder structure: folder structure

thanks , sorry if silly question, i'm brand new swift.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -