Swift WKWebView: Can't find variable error when calling method
<p>I am trying to pass GPS coordinates to a method call <code>setIOSNativeAppLocation</code>. I have the following code below but I am getting this error:</p>

<pre><code>A JavaScript exception occurred" 
UserInfo={WKJavaScriptExceptionLineNumber=1, WKJavaScriptExceptionMessage=
ReferenceError:
Can't find variable: setIOSNativeAppLocation, WKJavaScriptExceptionSourceURL=
http://mywebsite.com, NSLocalizedDescription=
A JavaScript exception occurred, WKJavaScriptExceptionColumnNumber=24})
</code></pre>

<p>I am not sure if it has something to do with the syntax or anything else. If someone knows what I am doing wrong I would greatly appreciate it.</p>

<hr>

<pre><code>func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {



   if(myCurrentLoc != nil){


      let lat = myCurrentLoc.coordinate.latitude
      let lon = myCurrentLoc.coordinate.longitude


      print(lat);
      print(lon);

      webView.evaluateJavaScript("setIOSNativeAppLocation(\(lat), \(lon));")  { (result, error) in
         guard error == nil else {
            print("there was an error")
            print(error)
            return
         }

      }
   }
}
</code></pre>