Code Monkey home page Code Monkey logo

vscode-ios-web-debug's Introduction


logo
VS Code - Debugger for iOS Web

Debug your JavaScript code running in Safari on iOS devices from VS Code.

Travis Release

Deprecation update

The iOS Web debugger has been deprecated, and we recommend you using remotedebug-ios-webkit-adaptor together with VS Code. A guide can be read here https://medium.com/@auchenberg/hello-remotedebug-ios-webkit-adapter-debug-safari-and-ios-webviews-from-anywhere-2a8553df7465.

Introduction

The VS Code iOS Web Debugger allows to debug your JavaScript code running in Safari on iOS devices (and iOS Simulators) from VS Code both on Windows and Mac without addtional tools.

Supported features

  • Setting breakpoints, including in source files when source maps are enabled
  • Stepping
  • Stack traces
  • Locals
  • Debugging eval scripts, script tags, and scripts that are added dynamically
  • Watches
  • Console
  • Virtual port forwarding via HTTP tunnel from local computer.

Unsupported scenarios

  • Debugging web workers
  • Any features that aren't script debugging.

Getting Started

Before you use the debugger you need to make sure you have the latest version of iTunes installed, as we need a few libraries provided by iTunes to talk to the iOS devices.

Windows

Nothing to do as there is a proxy included with the extension from the vs-libimobile npm package

OSX/Mac

Make sure you have Homebrew installed, and run the following command to install ios-webkit-debug-proxy

brew install ios-webkit-debug-proxy

iOS Device

On your iOS device then go to Settings > Safari > Advanced, and enable the Web Inspector option.

Using the debugger

When your launch config is set up, you can debug your project! Pick a launch config from the dropdown on the Debug pane in Code. Press the play button or F5 to start.

Configuration

The extension operates in two modes - it can launch a URL in Safari on the device, or it can attach to a running tab inside Safari. Just like when using the Node debugger, you configure these modes with a .vscode/launch.json file in the root directory of your project. You can create this file manually, or Code will create one for you if you try to run your project, and it doesn't exist yet.

To use this extension, you must first open the folder containing the project you want to work on.

Launch

Two example launch.json configs. You must specify either file or url to launch Chrome against a local file or a url. If you use a url, set webRoot to the directory that files are served from. This can be either an absolute path or a path relative to the workspace (the folder open in Code). It's used to resolve urls (like "http://localhost/app.js") to a file on disk (like "/users/me/project/app.js"), so be careful that it's set correctly.

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "iOS - Launch localhost with sourcemaps",
            "type": "ios",
            "request": "launch",
            "port": 9222,
            "url": "http://dev.domain.com/",
            "webRoot": "${workspaceRoot}",
            "deviceName": "*",
            "sourceMaps": true
        },
        {
            "name": "iOS - Launch localhost with sourcemaps via Tunnel",
            "type": "ios",
            "request": "launch",
            "port": 9222,
            "webRoot": "${workspaceRoot}",
            "deviceName": "*",
            "sourceMaps": true,
            "tunnelPort": 8080
        }
    ]
}

Attach

Attach to an already running browser tab in Safari by using the url to match the correct tab

An example launch.json config.

{
    "version": "0.1.0",
    "configurations": [
      {
          "name": "iOS - Attach",
          "type": "ios",
          "request": "attach",
          "port": 9222,
          "sourceMaps": true,
          "url": "http://dev.domain.com/",
          "webRoot": "${workspaceRoot}",
          "deviceName": "*"
      }
    ]
}

Other optional launch config fields

  • diagnosticLogging: When true, the adapter logs its own diagnostic info to the console
  • deviceName: The name of the devices, if multiple devices are connected. * matches any device.
  • tunnelPort: Port to be tunnel via local HTTP port. Usually the port your developer server is running on.

Troubleshooting

Please have a look at vscode-chrome-debug for additional troubleshooting and options.

=== This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

vscode-ios-web-debug's People

Contributors

andysterland avatar auchenberg avatar jalissia avatar roblourens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-ios-web-debug's Issues

Add support for inline source maps

I'm trying to get this work with my Mac and iPhone.

I read this page very carefully, and installed the prerequisites like brew package, but did not work.

I got this all the time:

Error [debugger-for-chrome] Got a response from the target app, but no target pages found

My Mac and iPhone are in the same WiFi network. The project is served from my Mac with a node dev server. I'm visiting the dev page on iPhone via URL like http://192.168.7.100:8080/. iPhone is plugged to Mac with the USB cable, and set to trust.

Here are my launch.json configs, none of these works:

    {
      "name": "Launch iOS Safari",
      "type": "ios",
      "request": "launch",
      "webRoot": "${workspaceRoot}",
      "sourceMaps": true,
      "port": 9222,
      "deviceName": "*",
      "url": "http://192.168.7.100:8080/*"
    },
    {
      "name": "Launch iOS Safari via Tunnel",
      "type": "ios",
      "request": "launch",
      "webRoot": "${workspaceRoot}",
      "sourceMaps": true,
      "port": 9222,
      "deviceName": "*",
      "tunnelPort": 8080
    },
    {
      "name": "Attach iOS Safari",
      "type": "ios",
      "request": "attach",
      "webRoot": "${workspaceRoot}",
      "sourceMaps": true,
      "port": 9222,
      "deviceName": "*",
      "url": "http://192.168.7.100:8080/*"
    }

I'm using Debugger for Chrome for macOS Chrome too, and it works perfectly. So I'm stuck here, cannot figure out what I was missing.

My environment and device:

  • Macbook Pro: macOS 10.12.1, VS Code 1.7.1, Debugger for iOS Web 0.1.2.
  • iPhone 6: iOS 10.1 (no iOS Chrome installed).

iOS 10 Support?

Would really love to use this but something tells me it doesn't like iOS 10, am I wrong? I can connect / debug my phone just fine via Safari desktop but VSC won't connect. Have read others having iOS 10 issues, let me know what else to try.

›OS: darwin x64
  ›Node: v6.5.0
  ›vscode-chrome-debug-core: 0.1.16
  ›debugger-for-ios-web: 0.1.2
  ›spawn('/usr/local/bin/ios_webkit_debug_proxy', ["--no-frontend","--config=null:9222,:9223-9323"])
  ›Discovering targets via http://127.0.0.1:9222/json
  ...
  ›Discovering targets via http://127.0.0.1:9222/json
  ›Discovering targets via http://127.0.0.1:9222/json
  ›Discovering targets via http://127.0.0.1:9222/json
  ›Error: Got a response from the target app, but no target pages found
    at Object.errP (/Users/troy/.vscode/extensions/msjsdiag.debugger-for-ios-web-0.1.2/node_modules/vscode-chrome-debug-core/out/src/utils.js:225:13)
    at /Users/troy/.vscode/extensions/msjsdiag.debugger-for-ios-web-0.1.2/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeTargetDiscoveryStrategy.js:13:26
    at process._tickCallback (internal/process/next_tick.js:103:7)

My launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Navigate to current project on an iOS device",
            "type": "ios",
            "request": "launch",
            "port": 9222,
            "diagnosticLogging": true,
            "url": "/test.html",
            "webRoot": "${workspaceRoot}/public",
            "deviceName": "*",
            "tunnelPort": 3000
        },
        {
            "name": "Navigate to url on an iOS device",
            "type": "ios",
            "request": "launch",
            "port": 9222,
            "diagnosticLogging": true,
            "url": "http://mysite.com/test.html",
            "webRoot": "${workspaceRoot}/public",
            "deviceName": "*"
        },
        {
            "name": "Attach to an iOS device",
            "type": "ios",
            "request": "attach",
            "url": "/test.html",
            "port": 9222,
            "diagnosticLogging": true,
            "webRoot": "${workspaceRoot}/public",
            "deviceName": "*"
        }
    ]
}

Specifying launch with URL fails with "Can't find a target that matches"

Running Windows 7; have the latest iTunes installed, iPhone 4S with iOS 9.3.5. I think the rest of my environment is in the debug console.

My project is accessible on my workstation via localhost:1234/docs/index.html

When I try launching the project, nothing happens on my phone, and I get this error:

[debugger-for-chrome] Can't find a target that matches: /docs/index.html. Available pages: ["about:blank"]

My launch configuration:

        {
            "name": "Navigate to current project on an iOS device",
            "type": "ios",
            "request": "launch",
            "port": 9222,
            "url": "/docs/index.html",
            "webRoot": "${workspaceRoot}",
            "deviceName": "*",
            "diagnosticLogging": true,
            "sourceMaps": true,
            "tunnelPort": 1234
        },

My debug console:

 ›OS: win32 ia32
  ›Node: v5.10.0
  ›vscode-chrome-debug-core: 0.1.16
  ›debugger-for-ios-web: 0.1.2
  ›Launching localtunnel against port 1234
  ›spawn('C:\Users\IGEN261\.vscode-oss\extensions\msjsdiag.debugger-for-ios-web-0.1.2\node_modules\vs-libimobile\lib\ios_webkit_debug_proxy.exe', ["--no-frontend","--config=null:9222,:9223-9323"])
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Success.1234
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Discovering targets via http://127.0.0.1:9223/json
  ›Error: Can't find a target that matches: /docs/index.html. Available pages: ["about:blank"]
    at _selectTarget (C:\Users\IGEN261\.vscode-oss\extensions\msjsdiag.debugger-for-ios-web-0.1.2\node_modules\vscode-chrome-debug-core\out\src\chrome\chromeTargetDiscoveryStrategy.js:48:19)
    at C:\Users\IGEN261\.vscode-oss\extensions\msjsdiag.debugger-for-ios-web-0.1.2\node_modules\vscode-chrome-debug-core\out\src\chrome\chromeTargetDiscoveryStrategy.js:15:22
    at process._tickCallback (internal/process/next_tick.js:103:7)

Any idea what might be going on?

Change webkit -> chrome

I changed all the 'webkit' names to 'chrome' in the chrome repo. Whenever you update, you'll have to use the new names.

Removed packageVersion parameter

It makes sense for the chrome part to log its own version, and for the ios extension to log its version itself. Both pieces of info will be useful instead of deriving the chrome version backwards from the ios extension verison.

Sourcemaps aren't being resolved correctly.

The paths seems to be resolved differently between our chrome debugger and this debugger.

Log comparision: https://gist.github.com/auchenberg/6a52c0bd8c5b47eac96f66a82a056ecc

The chrome debugger seems to resolve full paths, where the ios debugger resolves the map to relative paths. Same webRoot are set to the same in both cases.

launch.json

{
    "name": "iOS Attach",
    "type": "ios",
    "request": "attach",
    "port": 9221,
    "deviceName": "*",
    "proxyExecutable": "/usr/local/bin/ios_webkit_debug_proxy",
    "sourceMaps": true,
    "webRoot": "${workspaceRoot}/",
    "diagnosticLogging": true
}  

Demo project: http://github.com/auchenberg/timey

Attaches to Chrome instead of iOS Device on Windows

I've followed the instructions as I see them:

  1. Install iTunes
  2. Install extension
  3. Restart vscode
  4. Add a launch.json (see below)
  5. Try to attach to a tab/etc. from debugger pane

Result:
At this point it is just connecting to my machine's Chrome when what I really want is to connect to the tab that is open on my iOS device and connected via USB. If the tab is open in chrome it will attach to it, otherwise it gives me a "chrome-debugger-error: tab not found, available tabs are...".

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to an iOS device with URL",
            "type": "ios",
            "request": "attach",
            "port": 9222,
            "url": "http://www.example.com",
            "webRoot": "${workspaceRoot}",
            "deviceName": "*"
        }
    ]
}

Linux Support

In src/utilities.ts, Linux should be handled the same way as OSX/macOS and try to find ios_webkit_debug_proxy on the path

Second time starting launch scenario doesnt work

Steps:

  1. Start debugger first time, everything works
  2. Start second time, the output in the console, and debugger crashes,

Launch config:

        {
            "name": "Navigate to current project on an iOS device",
            "type": "ios",
            "request": "launch",
            "url": "/",
            "webRoot": "${workspaceRoot}",
            "deviceName": "*",
            "tunnelPort": 8080,
            "startLocalServer": false,
            "diagnosticLogging": false,
            "sourceMaps": true,
            "port" : 9222
        },

Error:

[debugger-for-chrome] Got response from target app, but no valid target pages found

Console:

 ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []
  ›Warning: Can't find a page with url: . Available pages: []

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.