ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
11.24k stars 955 forks source link

[Bug]: Can't Inspect WebView on iOS when setup with SPM #7406

Closed abegehr closed 1 month ago

abegehr commented 1 month ago

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.0.0 @capacitor/core: 6.0.0 @capacitor/android: 6.0.0 @capacitor/ios: 6.0.0

Installed Dependencies:

@capacitor/android: not installed @capacitor/cli: 6.0.0 @capacitor/core: 6.0.0 @capacitor/ios: 6.0.0

[success] iOS looking great! 👌

Other API Details

npm: 10.5.1
node: 20.9.0
pod: 1.14.3

Platforms Affected

Current Behavior

"No inspectable applications." on Safari for iOS projects setup with SPM (npx cap add ios --packagemanager SPM).

Expected Behavior

I'd expect to inspect the web view through Safari.

Project Reproduction

https://github.com/abegehr/capacitor-sample

Additional Information

When I delete the ios folder and re-init without SPM (npx cap add iOS), the web view is inspectable in safari as expected. Therefore I think it is a problem with the SPM setup.

jcesarmobile commented 1 month ago

Sadly on iOS the xcframeworks are always in Release mode, and for SPM we have to create .xcframeworks because Capacitor is mixed Objective-C and Swift source, which prevents from building a regular SPM. Since xcframeworks are in Release mode, by default WebView inspection doesn't work because the default value is to check if it's in DEBUG mode, which is always false for xcframeworks.

So, if you want to inspect the WebView you'll have to set ios.webContentsDebuggingEnabled to true in your capacitor config file, that makes the WebView inspectable even in production builds, but you have to remember to remove it before you publish the actual production build.

abegehr commented 1 month ago

Thank you for explaining, @jcesarmobile! I opened a PR on the docs repo to add a note on this: https://github.com/ionic-team/capacitor-docs/pull/299

ionitron-bot[bot] commented 2 days ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.