There are two requirements that must be fulfilled first though:
- Sign your app. This happens automatically on iOS, but is optional for an OSX app.
- Enable developer menu on Safari. Just open Safari, Preferences, and enable this highlighted-in-red check:
This is roughly 95% of the work. The other 5% is shockingly simple:
let scriptContents = try String( contentsOfFile: PATH_TO_YOUR_FILE, encoding: String.Encoding.utf8) // when evaluating scripts, just pass another parameter: context.evaluateScript( scriptContents, withSourceURL: URL(string: URLString)) // add withSourceURL to enable remote debugging
PATH_TO_YOUR_FILE is a valid path path to your Bundle files. Feel free to obtain your script contents from any source.
Setting a convenient URLString is paramount. E.g. you can set it to an external url where your map files exist. Don’t forget to use a URL prefix like file:// or http://.
One final note. This debugging capability will also be enabled in production after submitting files to the store. Since
withSourceURL parameter is optional you might want to set an