Using shadow-cljs to compile React Native for iOS on GNU/Linux
In the previous post I described how to set up and run an IOS simulator on Linux using a VirtualBox with MacOS image.
We used Re-Natal as a cli tool to bootstrap the application.
In this post we will look into using shadow-cljs to compile a vanilla react-native codebase. I find this combo to give a much lighter and snappier workflow, there is also a huge advantage in being closer to the react-native and npm ecosystem.
Before we begin please make sure you have the following tools set up:
- on the host platform:
- node and yarn
- VirtualBox with MacOS image
- samba server sharing the project folder
- on the guest platform
You can find all the instructions in this post.
Clone the project and make sure it is shared with the guest machine.
Lets start by installing all the dependencised. Go into the projects folder and install them:
Next start the shadow-cljs watcher:
Once it is done compiling in a separate terminal window start the react-native packager (Metro):
It will occupy port
Go to the guest machine running inside a VBox and use socat to start forwarding the port occupied by the Metro Bundler:
socat tcp-listen:8081,reuseaddr,fork tcp:192.168.1.3:8081
Now open the project in XCode and press Build and Run. Once it’s running use special +d to open developer menu on the simulator and make sure Live Reloading and Hot Reloading are both disabled:
If you edit the code on the host the changes are immediately reflected in the simulator running on the guest machine:
To connect a repl to the running project you can simply use
M+x cider-connect in Emacs.
localhost and select the port, thi swil connect you to the clj REPL, from which you can get a cljs REPL with:
Thanks for reading!