How to debug your web app running on a phone or emulator in your browser developer tools on Windows or Mac.
iPhone Emulator with Safari
- Install and run Xcode, install all updates
- Run Simulator
Select a phone & iOS - Load your web app in Safari on emulator
- Turn on Developer mode in Safari
Open Safari on the desktop
Safari > Preferences > Advanced tab > bottom checkbox for “Show develop menu in menu bar” - Select device from Develop menu, starts with “Simulator…” (see screenshot below)
Select your web app page/tab from the submenu - Debug away
iPhone with Safari
- Connect iPhone to Mac with USB cable
- Load your web app in Safari on iPhone
- Turn on Developer mode in Safari
Open Safari on the desktop
Safari > Preferences > Advanced tab > bottom checkbox for “Show develop menu in menu bar” - Select device from Develop menu by the device name (see iPhoneTD6 in screenshot above)
Select your web app page/tab from the submenu - Debug away!
Android Emulator with Chrome
- Install and run Android Studio
- Launch the Device Manager (Tools menu > AVD Manager)
- Create a Virtual Device
Phone, Pixel 2 or 3 (one WITHOUT the playstore icon), Pie (api 28), Android 9.0 (Google APIs, NOT Google Play)
Make note of the AVD id: “Pixel_3_API_28”
Accept other defaults (next, next, finish)
Do NOT start up the virtual device, yet
You can exit the AVD and Android Studio - Update hosts file on virtual device
Update your host ip in ~/Documents/hosts (“10.0.1.87 lxv-thale.local”)
cd ~/Library/Android/sdk/platform-tools
../emulator/emulator -avd Pixel_3_API_28 -writable-system
./adb root
./adb remount
./adb push ~/Documents/hosts /etc/hosts
Long press the power icon, choose restart - Open Chrome on the phone and go to your web app url
- Connect desktop Chrome to debug the emulator
Open Chrome on your COMPUTER
Go to chrome://inspect/#devices
Select your emulator device from the list (see screenshot below) - Debug away!
Android Phone with Chrome
The phone must be rooted to update your hosts file, so I don’t use this option.
- Root your phone
- Connect phone to computer with USB cable
Grant permission to computer - Open your web app in Chrome on the phone
- Update hosts file on phone
update your host ip in ~/Documents/hosts (10.0.1.87 lxv-thale.local)
Figure out how to copy this hosts file to your device to /etc/hosts - Connect desktop Chrome to debug the phone
Open Chrome on your COMPUTER
Go to chrome://inspect/#devices
Select your phone from the list (see screenshot above) - Happy debugging!