- Follow the detailed instructions to use an android studio emulator, via android studio, and/or an iOs simulator with xcode ( only possible on macOs) depending on your operating system
- Install the expo plugin for PyCharm, which provides easy to use templates for setting up and running
React Native
projects usingexpo
- Click
Create project
and use the installedexpo
template underOther
- Not sure if mandatory, but if an Error like "can only debug with Hermes" occurs, when trying to open the JS debugger (for debugging in Chrome) in the Expo menu, make sure to include
"jsEngine": "hermes"
in theapp.json
- If this does not work,
cold boot
your emulator - If you want to debug in PyCharm, you don't have to open the JS debugger in the Expo menu. Instead, execute a
cold boot
, run the app and then run the debug configuration as below.
-
Run the React Native application with Expo, i.e.
npx expo start --ios npx expo start --android
or
npx expo start
and thena
ori
or with the scripts provided by the PyCharm
expo
configuration plugin -
Set debugger points in PyCharm
-
Execute / DEBUG the created Debug configuration
-
PyCharm should stop at the breakpoints
- According to the IntelliJ IDEA React Native documentation, one should be able to execute steps 1.) and 2.) in one utilizing the "Before Launch" option in the Run Configuration
- This DID NOT work, maybe its not supported by PyCharm yet
- The referenced IntelliJ documentation is much more extensive than the PyCharm React Native documentation
- I pretty much followed the instruction on the IntelliJ Idea React Native - Debug Expo section
- The idea to first run the app and then separately the debug configuration came from here. It is also noted as ONE possibility on the IntelliJ IDEA documentation.
- The
host
andport
aspects noted in those documentations can be ignored. Maybeexpo
ormetro
changed their default port and host, not sure.
-
Run the React Native application as described above in point 2.)
-
Press
j
in the terminal running the server to open Chrome DevToolsor go to the developer menu in the simulator and click
Open JS Debugger
-
Set the breakpoints in the Chrome DevTools and reload the app
- The Chrome breakpoints did not always work as expected. This is also noted on the Expo Documentation
- Had to use
debugger
statements thereafter, which worked as expected - Above
debugger
statements led to issues when initially hosting the app - First run the app, then open Chrome DevTools, then insert the
debugger
statements in PyCharm and reload the app