Debugging Web Views
When working with hybrid apps that combine web technologies with native Swift functionality, debugging can be challenging. Issues often occur at the boundary between web and native code. This guide provides effective debugging strategies specifically for enClose applications.
Enable Debug Mode
- Set
debugMode = true
inMainViewController.swift
to make web views inspectable
Configure Your Device
Not required for Simulator
- Enable Web Inspector in Safari on your device by:
- Open the Settings app on your iOS device
- Scroll down and tap on Safari
- Scroll to the bottom and tap on Advanced
- Toggle on Web Inspector
Configure Safari on Your Mac
- Enable the Developer menu in Safari settings by checking
Show features for web developers
under the Advanced tab - Once enabled, Safari Developer Tools can connect to your web views
Debugging Features
When debug mode is enabled:
- Each native function call from enClose will be logged in the JavaScript console
- You can use Safari's debug tools and inspectors to:
- Monitor variables
- Modify style sheets
- Execute JavaScript directly in the context of your app