Skip to content

Attaching to Web Inspector for Debugging

Kasper Hirvikoski edited this page Jan 30, 2022 · 5 revisions

You can use Safari’s Web Inspector to debug Phoenix. Note, this only works on non-notarised versions of Phoenix (2.6.2 or older) or with debug builds. This can also be useful when you are developing your configuration since you can use the console as a shell (REPL). Follow the steps below to get started.

  1. Make sure Phoenix is running
  2. Open Safari
  3. Enable the “Develop” menu in Safari. To do this open Safari’s preferences and navigate to the “Advanced” tab. Make sure the option for “Show Develop menu in menu bar” is selected.

Advanced Preferences for Safari

  1. Open the “Develop” menu from the menu bar, find the menu item with the name of your device and hover over it
  2. You should see an item for Phoenix in the submenu. Click on “JSContext” under Phoenix.

Develop Menu for Safari

  1. A new Web Inspector window attached to Phoenix’s JavaScript context should open
  2. Open the “Console” tab and start exploring

Console for Web Inspector

Set a Breakpoint

  1. Make Safari open the Web Inspector automatically when it detects a breakpoint in your configuration. To do this, open the “Develop” menu from Safari’s menu bar, find the menu item with the name of your device and hover over it.
  2. Select the option for “Automatically Show Web Inspector for JSContexts”
  3. Write the debugger; statement somewhere in your configuration file, after Phoenix reloads the configuration, Web Inspector should open automatically and be paused on the breakpoint you set

Debugger for Web Inspector