Remote Debugging for Chrome iOS (and Safari)
Asked Answered
G

16

218

With the recent release of Chrome for iOS, I was wondering how do you enable remote debugging for Chrome iOS?

Update: With the release of iOS 6, remote debugging can now be done with Safari.

Garrote answered 29/6, 2012 at 12:58 Comment(3)
Remote debugging now can be done with Safari on Mac. But if you are developing on Linux or Windows you still have to use weinre (as stated in gregers answer).Ludly
Remote debugging with Safari only supports Mobile Safari, not iOS Chrome.Grassy
Please take a look medium.com/@nikoloza/…Salute
M
121

Update:

This is not the best answer anymore, please follow gregers' advice.

New answer:

Use Weinre.

Old answer:

You can now use Safari for remote debugging. But it requires iOS 6.

Here is a quick translation of http://html5-mobile.de/blog/ios6-remote-debugging-web-inspector

  1. Connect your iDevice via USB with your Mac
  2. Open Safari on your Mac and activate the dev tools
  3. On your iDevice: go to settings > safari > advanced and activate the web inspector
  4. Go to any website with your iDevice
  5. On your Mac: Open the developer menu and chose the site from your iDevice (its at the top Safari Menu)

As pointed out by Simons answer one need to turn off private browsing to make remote debugging work.

Settings > Safari > Private Browsing > OFF

Marris answered 26/9, 2012 at 17:23 Comment(10)
Yep, I'm already using this one. Finally! It sucks that the windows version of Safari does not have it though.Garrote
I hope Chrome will enable the same feature soon, so that it works across all OS.Marris
I think apple will have to enable remote debugging for WebViews and not just mobile safari for this to work since chrome is just using webviews.Garrote
Yes - on an IOS device, apple does not allow alternative installs of webkit and all apps must use the webkit version installed on the device. So Chrome on an IOS device is just webviews with chrome tool bars :)Andrus
For iOS 7 you need to install Safari 6.1 in order to use remote debugging which right now is only available for developers and requires at least OS X 10.7: developer.apple.com/downloads/index.action?name=Safari%206.1Lakh
Yes - it sure would be nice if this answered the question that was asked!Heywood
Turning private browsing off is no longer a requirement.Closeup
Downvote reason: Questions asks for Chrome not Safari.Moffitt
Guys, if we had a mac and were apple minded i'm sure we wouldn't ask this question ...Seiber
upvoted for sending into better answer :) that what I call good SO usersSaraband
A
237

The selected answer is only for Safari. At the moment it's not possible to do real remote debugging in Chrome on iOS, but as with most mobile browsers you can use WeInRe for some simple debugging. It's a bit work to set up, but lets you inspect the DOM, see styling, change DOM and play with the console.

enter image description here

To setup:

  • Install nodejs
  • npm install -g weinre
  • weinre --boundHost -all-
  • Open http://{wifi-ip-address}:8080/ and copy the target script code
  • Paste the script tag into your page (or use the bookmarklet)
  • Click on the link to the debug client user interface (http://{wifi-ip-address}:8080/client/#anonymous)
  • When you get a green line under Clients the browser is connected

The bookmarklet is a bit more of an hassle to install. It's easiest if you have bookmark-sync turned on for both desktop and mobile Chrome. Copy the bookmarklet url from the local weinre server (same as above). Unfortunately it doesn't work because it's not url-encoded properly. So open the JavaScript console and type in:

copy(encodeURI('')); // paste bookmarklet inside quotes

You should now have the url-encoded bookmarklet in your clipboard. Paste it into a new bookmark under Mobile Bookmarks. Call it weinre or something simple to type. It should be synced to your mobile pretty fast, so load the page you want to inspect. Then type in the bookmark name in the url-bar, and you should see the bookmarklet as an auto-complete-suggestion. Click it to run bookmarklet code :)

enter image description here

Atul answered 26/2, 2014 at 16:33 Comment(20)
This is the only correct answer, all other relate to Safari (walk in a park)Lasonyalasorella
Very helpful instructions! I'll just add that, to install the bookmarklet, instead of doing the copy, you can just drag the provided "weinre target debug" bookmarklet link to your bookmarks toolbar (make the toolbar visible with Ctrl-Shift-B if it's not visible).Breadstuff
I needed to refresh my browser after installing the bookmarklet to get it to work.Erlandson
npm install -g weinre was not working for me. So I had to run it with the version npm install -g [email protected]. check latest version here npmjs.com/package/weinre.Genip
Do your phone and your pc have to be on the same network? I noticed that the 4th bullet point calls for the wifi-ipBurgher
@Burgher Yes, both needs to be connected to the same wifi network, or use a publicly available IP/domain instead of wifi-ip-address.Atul
fwiw, to debug sites that are accessible through https only, follow these instructions. The given command line to launch ngrok is missing a http (ngrok command), otherwise it worked like a charm.Heartbreaking
browser-sync comes with this and seems like it is a bit easier to install. browsersync.io It also has a couple of other things worth the install.Vanburen
This worked for me without URL encoding the bookmarklet in Mobile Safari.Harvest
You'll have to add the script tag to the BOTTOM of the page.Novelistic
Downvoted. I hope you understand that it is too hard to use a tutorial which contains a lot of missed info. Open http://{wifi-ip-address}:8080/ and copy the target script code - what is that? Where is wi-fi appeared? I use a pc without wi-fi + device with wi-fi - what should I do. And the same for next steps - totally unclear and useless without of additional info.Enugu
@VyachaslavGerchicov Sorry, it's hard to find the balance between too much and too little info. You need an IP-address to your development computer from your iOS device to connect to the WeInRe server. The easiest is to connect both to the same WiFi-network and type in the IP-address of your computers WiFi network interface. How to do this depends on computer and OS, so you need to google how to do that on your computer. When you find the IP-address and open the page (http://{wifi-ip-address}:8080/) - you'll find the target script code and probably other parts you're missing.Atul
ngrok seems to want me to pay to use TLS, anyone gotten around that?Sibyls
FWIW, weinre doesn't currently support shadow dom - it only shows the top level elements and their light dom. It also doesn't work for shady dom apart from the top-level elements and their shady-dom (and light dom too).Jerusalem
FYI, Vorlon (recommended in one of the answers) is way easier to setup.Regenaregency
This should be the accepted answer. The current accepted answer is not even addressing the technical question whether Chrome for iOS can be debugged by using the common approach of attaching a remote debugging console. weinre is likely the best solution for iOS debugging right now (if you can't use Web Inspector for iOS), but unsuitable for some tasks (try debugging a service worker with that)...Boost
@Vanburen Browser-sync a bit easier to install? How do I set it up at all for this use case? Stared at the site for 10 minutes, still have no idea. What happens after I install it, how can I debug the page on my phone remotely now? The site says nothing about it. It says something about grunt and gulp, I don't use them, now what?Scipio
weinre doesn't support https, this is a big problemIntramolecular
weinre homepage now has a huge banner warning that it is out of dateMister
Another option for Chrome: medium.com/@nikoloza/…Salute
M
121

Update:

This is not the best answer anymore, please follow gregers' advice.

New answer:

Use Weinre.

Old answer:

You can now use Safari for remote debugging. But it requires iOS 6.

Here is a quick translation of http://html5-mobile.de/blog/ios6-remote-debugging-web-inspector

  1. Connect your iDevice via USB with your Mac
  2. Open Safari on your Mac and activate the dev tools
  3. On your iDevice: go to settings > safari > advanced and activate the web inspector
  4. Go to any website with your iDevice
  5. On your Mac: Open the developer menu and chose the site from your iDevice (its at the top Safari Menu)

As pointed out by Simons answer one need to turn off private browsing to make remote debugging work.

Settings > Safari > Private Browsing > OFF

Marris answered 26/9, 2012 at 17:23 Comment(10)
Yep, I'm already using this one. Finally! It sucks that the windows version of Safari does not have it though.Garrote
I hope Chrome will enable the same feature soon, so that it works across all OS.Marris
I think apple will have to enable remote debugging for WebViews and not just mobile safari for this to work since chrome is just using webviews.Garrote
Yes - on an IOS device, apple does not allow alternative installs of webkit and all apps must use the webkit version installed on the device. So Chrome on an IOS device is just webviews with chrome tool bars :)Andrus
For iOS 7 you need to install Safari 6.1 in order to use remote debugging which right now is only available for developers and requires at least OS X 10.7: developer.apple.com/downloads/index.action?name=Safari%206.1Lakh
Yes - it sure would be nice if this answered the question that was asked!Heywood
Turning private browsing off is no longer a requirement.Closeup
Downvote reason: Questions asks for Chrome not Safari.Moffitt
Guys, if we had a mac and were apple minded i'm sure we wouldn't ask this question ...Seiber
upvoted for sending into better answer :) that what I call good SO usersSaraband
C
53

You cannot directly remote debug Chrome on iOS currently. It uses a uiWebView that may act subtly different than Mobile Safari.

You have a few options.

Option 1: Remote-debug Mobile Safari using Safari's inspector. If your issue reproduces in Mobile Safari, this is definitely the best way to go. In fact, going through the iOS simulator is even easier.

Option 2: Use Weinre for a slimmed down debugging experience. Weinre doesn't have much features but sometimes it's good enough.

Option 3: Remote debug a proper uiWebView that functions the same.

Here's the best way to do this. You'll need to install XCode.

  1. Go to github.com/paulirish/iOS-WebView-App and "Download Zip" or clone.
  2. Open XCode, open existing project, and choose the project you just downloaded.
  3. Open WebViewAppDelegate.m and change the urlString to be the URL you want to test.
  4. Run the app in the iOS Simulator.
  5. Open Safari, Open the Develop Menu, Choose iOS Simulator and select your webview.
  6. Safari Inspector will now be inspecting your uiWebView.

enter image description here

enter image description here

enter image description here

Coach answered 12/9, 2014 at 22:22 Comment(3)
How to inspect iOS (iPhone / iPad) on a Windows using chrome? Is there any method for that?Balcom
@SurjithSM This answer will not help with windows while you can't install XCode on windows and create ios app. Try this instead https://mcmap.net/q/125308/-remote-debugging-for-chrome-ios-and-safariHedonism
I've already had experience with github.com/google/ios-webkit-debug-proxy which is awesome tool, and yesterday tried debugging Google Chrome with iOS Emulator - it most awesome experience. Thanks for #3Woolson
N
12

From my understanding, Google Chrome utilizes the iOS's UIWebView rather than a full blown implementation of Chrome like the Android counterpart.

Nelson answered 20/7, 2012 at 4:32 Comment(1)
Yeah, found that out after I put up this question. That is a shame for apple really. I'm left this question open on the off chance that someone figured out a way to do it.Garrote
L
5

I recommend Vorlon, works like weinre. I like the UI of Vorlon, and it support SSL, my application is in HTTPS, I tried weinre with ngrok, ghostlab and vorlon, only vorlon works fine.

Lyricism answered 10/4, 2017 at 2:17 Comment(0)
L
3

You also need to have 'Private Browsing' turned OFF.

Settings > Safari > Private Browsing > OFF

Leicestershire answered 15/3, 2013 at 9:14 Comment(3)
not sure why ppl downvote this answer. private browsing needs indeed to be switched off to allow remote debugging.Livingston
@Livingston Because it is a complementary answer which it should be in the comment.Kimura
@Kimura I see, thanks! A comment by a downvoter that explains this would have been helpful.Livingston
T
3

Many remote consoles work fine. http://farjs.net is my project, and I was able to successfully debug issues specific to Crome iOS and not happening in safari using it. (and probably all other mobile browsers)

The problem is that injecting the debugging code is slightly tricky since Chrome doesn't allow you to install bookmarklets.

Instead you could open one tab on the page that you would debug, and another on farjs.com and then click "the bookmarklet"

Copy the bookmarklet JS code, get back to the first tab, with the page that should be debugged, and paste the bookmarklet code in the location bar.

Last step is to scroll to the beginning of the location bar and add "javascript:", since Chrome will remove it.

Teaser answered 25/9, 2014 at 1:10 Comment(2)
broken url farjs.comLeaguer
Yeah, I renamed it to farjs.net since it's cheaper domain.Teaser
T
3

I haven't tried it, but iOS WebKit debug proxy (ios_webkit_debug_proxy / iwdp) supposedly lets you remotely debug UIWebView. From the README.md

The ios_webkit_debug_proxy (aka iwdp) allows developers to inspect MobileSafari and UIWebViews on real and simulated iOS devices via the Chrome DevTools UI and Chrome Remote Debugging Protocol. DevTools requests are translated into Apple's Remote Web Inspector service calls.

Teraterai answered 26/10, 2015 at 11:45 Comment(1)
Support for Chrome webview is theoretically implemented via: github.com/RemoteDebug/remotedebug-ios-webkit-adapter which is built on top of iOS webkit debug proxy. I've had limited success with that project myself so far, but I expect it will get better.Grassy
T
3

Vorlon.JS can be used for remote debugging of iOS or any other client.

  1. Just install it globally using npm i -g vorlon
  2. Start server using vorlon
  3. With the server is running, open http://localhost:1337 in your browser to see the Vorlon.JS dashboard
  4. The last step is to enable Vorlon.JS by adding this script tag to your app:
    <script src="http://<yourExternalIP>:1337/vorlon.js"></script>
  5. All connected clients e.g. iPhone, Android will become available in client list on Vorlon.JS dashboard enter image description here

Note that this approach can also be used to debug apps not running on localhost using ngrok. See https://mcmap.net/q/128253/-accessing-ios-safari-web-inspector-from-windows-machine for details.

Disclaimer

I am just a user and I am not affiliated with Vorlon.JS and ngrok

Terramycin answered 6/8, 2017 at 12:3 Comment(1)
I followed all the steps but my iPhone's outlook is not getting detected in the VorlonJS running in MacDosh
B
3

iOS WebKit debug proxy is the simpliest solution - debug and live preview directly in Chrome.

Blockhouse answered 19/10, 2020 at 10:15 Comment(0)
G
2

I am using remotedebug-ios-webkit-adapter, works well for me with IOS and debugger open in Chrome on Windows 10.

Will be glad if it helps some one Link

Genipap answered 24/1, 2018 at 8:13 Comment(0)
V
2

2023 Update

with iOS 16.4+ you can remote debug iOS Chrome using Safari on a desktop/laptop, just like iOS Safari. Full instructions here:

https://developer.chrome.com/blog/debugging-chrome-on-ios/

Vastha answered 1/8, 2023 at 2:30 Comment(0)
S
1

Even I am looking for the same feature, and as of today, its yet to be implemented. I can think of two options however,

  1. I noticed that the behavior of Chrome and Safari are quite identical; Chrome even supports the Gyroscope and other related events which are supported by Safari. I am currently debugging my Web App by enabling the debug console on Safari (Through Settings->Safari)

  2. Also try Adobe Shadow, which allows remote debugging/inspection and Sync.

HTH.

Stillwell answered 8/7, 2012 at 9:40 Comment(0)
T
1

Adobe Edge Inspect (https://creative.adobe.com/products/inspect) is another way to debug all your mobile devices IOS and Android (no Windows Phone though). It uses weinre for remote DOM inspection/changing. It's not the fastest of methods, but it works on Windows.

Tidbit answered 6/8, 2014 at 12:54 Comment(3)
Adobe Edge Inspect is no longer listed in Adobe Creative Cloud. See adobe.com/products/edge-inspect.html.Ingraham
True, however you can still download it with a current subscription, despite the fact that it is no longer under development. See how to do it here: helpx.adobe.com/creative-cloud/kb/…Costermonger
However, the iOS app is no longer available. Still working on Android, but no iOS anymore: itunes.apple.com/app/id498621426Statesmanship
E
1

Note: I have no affiliation with Ghostlab creators Vanamco whatsoever.

It was important to me to be able to debug Chrome-specific problems, so I set out to find something that could help me with that. I ended up happily throwing my money at Ghostlab 3. I can test Chrome and Safari mobile browsers as if I was viewing them on my desktop. It just gives me a LAN address to use for any device I’d like to debug. Each application using that address will appear in the list in Ghostlab.

enter image description here

enter image description here

Highly recommended.

Exchequer answered 29/8, 2018 at 17:37 Comment(0)
B
0

There is an open bug on Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=584905

Unfortunately they depend on Apple to open up an API in WKView for this to happen, after which maybe debugging will be available from Safari.

Biggerstaff answered 4/4, 2016 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.