I've recently got annoyed that I had to do manual reloads (usually click focus simulator + cmd + ctrl + z + click reload + click focus IDE) from outside of my IDE, so here's my little adventure trying to make a shortcut that interacts with the simulator or the android emulator in Jetbrains

For android we have a solution straightforward solution, just run an adb command and add it as an external tool + hook into the shortcut:

adb shell input keyevent 82

For iOS it was a little bit complicated.. I first thought of using simctl to do commands but that doesn't seem to do anything similar to what adb does, so I came up with an apple script (based on this):

tell application "System Events"-- Activate the Simulator if it's not already frontmost
    tell application "Simulator" to activate

    -- Simulate the key press: Ctrl + Cmd + Z
    keystroke "z" using {control down, command down}
end tell

With it, I can just run osascript ./file.applescript and the reload menu will work, I can then hook it into an external action + bind the keyboard shortcut

Although this one was ok, I realized with this comment that we can just curl the dev server:

curl localhost:8081/reload

And since reload is mainly the command I use, I'll be just using it instead of the menu

<aside> 💡

Note: I might get back to the applescript cuz sometimes RN loses connection with metro and metro commands will not work... but lets see

</aside>