It's not just a wkwebview, it's a single page app running inside a wkwebview which is the popover of Safari app extension. I need to communicate between my SafariExtensionViewController and this spa inside wkwebview. I totally lost the idea of how to deal with it.
if you want to debug javascript code that wkwebview is presenting you need to go to Safari -> Preferences -> Advanced -> Show Develop Menu In Menu Bar
then a new tab will appear on Safari "Develop" press on it and select the simulator or the device that your app is running on (if you don't see any device or a simulator its because you ran Safari before the app was running. close it by left click -> close and open it again, it will work)
it will show you the html that the app is currently presenting.. press on it the you have the option to debug your app, see logs/error on the console
hope I helped