swift instead javascript

I'm creating a framework that allows you to easily create html and css web pages in ios style.

As long as it's static components that don't have events (e.g. a webpage with a paragraph), that's okay. The problem arises when I have to create a button, recognize and capture the click event. In the same way, however, I have the problem of recognizing and capturing all the other browser events (e.g. the page is loaded into memory). In web development this is handled by javascript. But I would like to replace javascript with my framework and with swift.

So how do I interact with browser events? do i have to install swift in the browser? how can I do?

thank you

  1. You cannot replace Javascript in the browser with swift

  2. Take a look at the JavaScriptCore framework JSContext & JSVirtualMachine API that will allow you to run Javascript natively in a JSVirtualMachine bridging to Swift or Objective-C API calls. https://developer.apple.com/documentation/javascriptcore/jscontext

  3. For Webviews using WKWebit take a look at https://developer.apple.com/documentation/webkit/wkuserscript, https://developer.apple.com/documentation/webkit/wkusercontentcontroller

swift instead javascript
 
 
Q