apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

feat: New webkit feature - Inspectable WebKit, inspect production apps #1303

Closed gee1k closed 1 year ago

gee1k commented 1 year ago

Bug Report

Problem

What is expected to happen?

Unable to open inspect via Safari on iOS16

https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/

erisu commented 1 year ago

Alread been resolved. https://github.com/apache/cordova-ios/pull/1300

knubie commented 1 year ago

I'm running Cordova iOS 6.3 and I still can't seem to inspect the app through Safari. Is anyone able to offer some guidance on how to go about debugging this?

Screenshot 2023-04-23 at 10 41 48 AM

Screenshot 2023-04-23 at 10 41 10 AM

breautek commented 1 year ago

I'm running Cordova iOS 6.3 and I still can't seem to inspect the app through Safari. Is anyone able to offer some guidance on how to go about debugging this

The feature requires the app to be built with the iOS 16.4 SDK, which I believe you have since you're using a simulator. iOS 16.4 SDK is used on XCode 14.3.

If you're building a production --release app, debugging is disabled by default, maintaining the previous behaviour. So make sure that you're building a debug mode application.

Alternatively you can use the InspectableWebview preference to always enable or disable the inspector, regardless of build type. However It would be recommended to leave this preference unset to let Cordova default it to enabled only in debug builds.

We do have a Docs PR with this information pending: https://github.com/apache/cordova-docs/pull/1291

knubie commented 1 year ago

Thanks @breautek!

The feature requires the app to be built with the iOS 16.4 SDK, which I believe you have since you're using a simulator. iOS 16.4 SDK is used on XCode 14.3.

Indeed, the simulator is running iOS 16.4 (per previous screen shot), Xcode is 14.3 Screenshot 2023-04-23 at 12 35 17 PM

If you're building a production --release app, debugging is disabled by default, maintaining the previous behaviour. So make sure that you're building a debug mode application.

As far as I can tell I'm running in debug mode (this is the command I'm using: cordova run ios --target=iPhone-14). However, even if I weren't, I have already set <preference name="InspectableWebview" value="true" /> in my config.xml, anyway, so I think it should work regardless.

I've also tried the latest Safari Technology Preview, to no avail.

I appreciate the suggestions. Please let me know if you can think of any other variable that I may be overlooking. I've already try restarting my Mac, with no success.

knubie commented 1 year ago

Okay, I figured out my issue. I am using the plugin ionic-team/cordova-plugin-ionic-webview which obviously overrides the webview implementation. Updating the code in the plugin makes the app inspectable again. (In fact there's even a PR for the issue)

That said, I added that plugin to my project ~3 years ago because, I think, it used the newer wkwebivew engine. It looks like cordova uses wkwebview now, so perhaps I don't need this plugin any more.

itbeyond commented 1 year ago

@knubie - I am in the same position. I did some testing removing the ionic-team/cordova-plugin-ionic-webview but I could not get the app past the splash screen it just hung, I even tried remove/add platform ios. Did you make it work?

knubie commented 1 year ago

@itbeyond I have not tried to remove the plugin yet. I just forked the repo and applied the changes. That seemed to be the path of least resistance for me.

https://github.com/mochi-cards/cordova-plugin-ionic-webview/commit/8ed55aceeb659c16d6a6de2717c29c684c6f9222

If the app is hanging at the splash screen, are there any errors in the XCode logs?

dpogue commented 1 year ago

If you have problems with the cordova-plugin-ionic-webview, please open an issue in the repository for that plugin and continue the discussion there.

cordova-ios 6.3.0 has been released, which includes the ability to inspect the standard Cordova WKWebView on iOS 16.4. If you are not using the standard Cordova WKWebView, you will need to follow up with the maintainers of the 3rd party webview plugin.