Debug iPhone Safari on Mac: Step-by-Step Guide
In this article
This guide shows you how to use Safari's built-in Web Inspector on your Mac to debug and inspect websites running on your iPhone. This is essential for testing responsive layouts, debugging JavaScript errors, and inspecting network requests on actual iOS devices. Before you start, make sure both your iPhone and Mac are signed into the same Apple ID, have Wi-Fi and Bluetooth enabled, and are within range of each other.
What You'll Need
- A Mac running macOS Catalina or later (Safari's Develop menu is available in all recent versions).
- An iPhone running iOS 13 or later (older versions work too, but steps may vary slightly).
- A USB cable to connect your iPhone to your Mac (optional if you use Wi-Fi debugging).
- Both devices signed into the same Apple ID.
- Both devices have Wi-Fi and Bluetooth turned on (required for wireless debugging).
Step-by-Step
- Enable the Develop menu on your Mac: Open Safari on your Mac. In the menu bar at the top, click Safari → Settings (or Preferences in older versions). Go to the Advanced tab and check the box next to Show features for web developers. Close the settings window. You should now see a Develop menu in the menu bar.
- Enable Web Inspector on your iPhone: On your iPhone, go to Settings → Safari → Advanced (scroll to the bottom). Toggle on Web Inspector. If you don't see this option, make sure you're running iOS 13 or later.
- Connect your iPhone to your Mac (wired or wireless):
- Wired: Use a Lightning or USB-C cable to connect your iPhone to your Mac. If you see a prompt on your iPhone asking Trust This Computer?, tap Trust and enter your passcode.
- Wireless: After you've connected via cable once and trusted the computer, you can disconnect the cable. On your Mac, open Safari, go to the Develop menu, and select iPhone (or your device name). If it doesn't appear, ensure Wi-Fi and Bluetooth are on for both devices and that they are on the same Wi-Fi network. You may need to re-enable wireless debugging in Xcode if you've used it before, but for most users, the cable method is simpler.
- Open the page you want to debug on your iPhone: Launch Safari on your iPhone and navigate to the URL you want to inspect. Make sure the page is fully loaded.
- Open Web Inspector on your Mac: On your Mac, in Safari, click the Develop menu. You'll see your iPhone's name listed. Hover over it and select the page you want to inspect (it will show the page title or URL). A new window will open with Web Inspector, similar to Safari's developer tools on Mac.
- Use the inspection tools: The Web Inspector has several tabs:
- Elements: Inspect and edit HTML and CSS in real-time. Click any element to see its styles, and you can modify them to test changes live.
- Console: View JavaScript errors, log messages, and run JavaScript commands directly in the context of the page.
- Sources: Debug JavaScript with breakpoints, step through code, and inspect variables.
- Network: Monitor all network requests, including XHR/fetch calls, and see their status, timing, and payloads.
- Storage: Inspect cookies, local storage, and session storage.
- Test responsive design: Use the Elements tab to toggle device simulation or simply resize the viewport by dragging the browser window. However, for true device testing, you can use the Develop menu → User Agent to spoof a specific iPhone model if needed.
- Disconnect when done: When you're finished, close the Web Inspector window and unplug the cable (if wired). The Develop menu will still show your iPhone when it's connected, but you can ignore it.
Common Mistakes
- Forgetting to enable Web Inspector on the iPhone: If you don't toggle this on, the iPhone won't appear in the Develop menu.
- Not trusting the computer: When you connect via USB, you must tap Trust on your iPhone. If you skip this, the connection will fail.
- Using the wrong cable: Some third-party cables only charge and don't support data transfer. Use an Apple cable or a certified MFi cable.
- Not having the Develop menu enabled: Without this, the Develop menu won't appear in Safari, and you can't access Web Inspector.
- Expecting wireless debugging to work without initial wired setup: For wireless debugging, you must first connect via USB and trust the computer at least once.
Tips
- Use the Console tab to run JavaScript snippets directly on the iPhone's page. This is handy for testing functions without editing the source.
- In the Elements tab, you can right-click an element and select Copy as HTML to export the current state.
- Use the Network tab to check the exact load times of resources on a real iPhone, which can be slower than a desktop.
- If you're debugging a PWA or a standalone web app, open it from the home screen to test its standalone behavior.
- Keep both devices updated to the latest iOS and macOS versions to avoid compatibility issues.
Troubleshooting
My iPhone doesn't appear in the Develop menu.
- Check that Web Inspector is enabled on the iPhone (Settings → Safari → Advanced).
- Ensure the Develop menu is enabled on the Mac (Safari → Settings → Advanced → Show features for web developers).
- Reconnect the USB cable and tap Trust on the iPhone if prompted.
- Restart both Safari on the Mac and the iPhone's Safari.
- If using wireless, make sure both devices are on the same Wi-Fi network and have Bluetooth on.
Web Inspector opens but shows a blank page.
- Refresh the page on the iPhone and wait a few seconds for the inspector to reload.
- Close and reopen the Web Inspector window.
- Ensure the page on the iPhone is fully loaded before opening the inspector.
JavaScript debugging doesn't work.
- Make sure you're using the Sources tab, not the Console, for breakpoints.
- Check that the page is not a service worker or a cached version; try a hard reload on the iPhone (Settings → Safari → Clear History and Website Data).
Wireless debugging stops working.
- Reconnect via USB once to re-establish trust, then disconnect again.
- Toggle Wi-Fi and Bluetooth off and on on both devices.
- Restart Safari on the Mac.
Frequently Asked Questions
Can I debug Chrome or Firefox on iPhone?
No, all browsers on iOS use WebKit (Safari's engine), so you must use Safari's Web Inspector to debug any browser on iPhone, including Chrome and Firefox.
Do I need a developer account to use Web Inspector?
No, Web Inspector is free and built into Safari. You just need to enable the Develop menu and Web Inspector on your devices.
Can I debug a website that is not in my local network?
Yes, as long as the iPhone can load the website (e.g., a public URL), you can inspect it. The connection between iPhone and Mac is local, not dependent on the website's server.
Why can't I see the Develop menu on my Mac?
You need to enable it in Safari's Advanced settings. If you don't see the checkbox, make sure you're looking at the correct settings pane (Advanced tab).
Is it possible to debug an iPhone from a Windows PC?
No, Web Inspector is only available on macOS. On Windows, you can use remote debugging with Chrome for Android, but not for iPhone.
What if my iPhone is too old to support Web Inspector?
Web Inspector has been available since iOS 6, so any iPhone that can run a reasonably recent iOS version should support it. If you have an extremely old device, consider using a simulator on your Mac instead.