After upgrading `react-native` to `0.72.5` we frequently started seeing the _red screen of death_ on both `Android` and `iOS` simulators right after the app was built and installed. This used to happen because our workflow required us to do the following : - `make run-clojure` - `make run-metro` - `make run-ios` OR `make run-android` The problem with this approach was after `metro` was started the `iOS`, `Android` build step would change the files that `metro` couldn't handle and hence metro would go out of sync. The quick fix back then was to restart `metro` terminal and to open the app again from the simulator. This was however not a good DX. This commit fixes that. We no longer rely on `react-native` cli to generate and deploy debug builds on simulators. We take control of the process via our own script. The new workflow introduced in this commit will first build the app, then install the app on the simulators and then start metro terminal. When `metro` is successfully running the script will then open the app. The new workflow now is : - `make run-clojure` - `make run-ios` OR `make run-android`
6.8 KiB
Setup your Editor/IDE
You can use any Clojure enabled editor. Here are instructions for developing the status-mobile app using:
- IntelliJ IDEA and Cursive
- VS Code and Calva
- Emacs/Cider
(Please add instructions for your favorite editor.)
Table of Contents
Using Cursive
Install Cursive
See https://cursive-ide.com/userguide/index.html
Getting Cursive to understand status-mobile
- Add this file to the root of the
status-mobile
project dir - Right click and "add as leiningen project"
I get a lot of cannot be resolved
Are you getting problems where you get a lot of cannot be resolved
on everything?
See https://cursive-ide.com/userguide/macros.html
- opt+enter (on macOS)
- resolve defview as fn and letsubs as let
- move selection on resolve and hit enter
- and select defn for defview and let for letsubs
REPL!
Connecting to REPL to IntelliJ
I had a number of problems connecting to REPL, the solution is as follows:
At the top of IntelliJ IDEA click on the Add Configuration...
option:
This will load the following menu:
Click on the +
icon in the top left corner of the menu.
Select Clojure REPL > Remote
Which will load the following menu
Enter the below options:
- Name = status-mobile
- Display Name = status-mobile
- Connection type = nREPL
- Connection details
- Host = 127.0.0.1
- Port = 7888
Press OK
Now the below option will be visible. Press the green run button
You should now see a dialog with the following message:
Connecting to remote nREPL server...
Clojure 1.10.1
To confirm you have a working connection with REPL enter the following command in the input box below the output:
(prn 1)
Which should output
(prn 1)
1
=> nil
See below:
Connecting REPL and IntelliJ to status-mobile
The important next step is telling REPL the context in which to interact with the code.
Do the following:
Ensure you have 2 terminals running the following
make run-clojure
make run-ios
/make run-android
See the STARTING GUIDE for details
Next go back to the REPL input and enter the following commands:
(shadow/watch :mobile)
(shadow/repl :mobile)
See Below
Which should switch the clj file type target to cljs as shown above
Finally you are ready to test REPL.
Create a sample function to evaluate something simple like (prn "I'm working")
, move your cursor to one of the outer parentheses. Right or control
click and select the REPL
option. From there select Sync files in REPL
and then Send '...' to REPL'
.
Alternatively you can use the shortcut commands ⇧⌘M
to sync your files and ⇧⌘P
to send the statement to REPL. You may also need to switch the REPL namespace to match the current file, which can be done manually from the dialogue box or using the ⇧⌘N
shortcut key.
Following the above should give you the below result:
🎉 Tada! Working! 🎉
For additional details on issues you may face when setting up REPL with Cursive see this document
Visual Studio Code
Set up the REPL
- Install Calva extension.
- Open the
status-mobile
folder. - Start Status development (Starting the
run-clojure
andrun-metro
jobs in split view in the VS Code integrated terminal works great). - Run the VS Code command: Calva: Connect to a running REPL Server in the
project.
- Select the project type
shadow-cljs
. - Accept the suggested connection
host:port
. - Select to connect to the
:mobile
build.
- Select the project type
Open any .cljs
file in the project and evaluate forms in it. See
https://calva.io/try-first/ for some starter tips and links. Confirm that your
REPL is connected to the app by evaluating:
(js/alert "Hello from Status App!")
🎉 Tada! You are ready to use the REPL to improve Status.im! 🎉
Consider bookmarking calva.io for quick access to the Calva documentation.
Auto-format files on save
We format Clojure code with zprint. We
recommend configuring VSCode to auto-format Clojure files on every save,
otherwise you'll need to constantly rely on the much slower make lint-fix
command.
- Create a file
~/.zprintrc
and enable the:search-config?
option. This is necessary so the VSCode extension finds the project's.zprintrc
.
echo "{:search-config? true}" > ~/.zprintrc
- Install the extension vscode-clj-zprint. By the way, did you know this extension is written in ClojureScript?
- Copy the recommended settings from our repository in
.vscode/settings.example.json and merge it
with your workspace settings in
.vscode/settings.json
.
The extension vscode-clj-zprint
is only available for VSCode. If you are using
VSCodium, you'll need to build the vsix
(extension) yourself (it's easy, only
yarn
and vsce
are required).
Using Emacs with CIDER
- Install Emacs/Cider/etc. (there is a lot of variability in how to manage things in emacs, so please google for help with this)
- Add a local ~/.shadow-cljs/config.edn file like below (corresponding to the version numbers of the packages you are using):
{:dependencies
[[nrepl/nrepl "0.9.0"]
[cider/cider-nrepl "0.28.4"]
[cider/piggieback "0.5.2"]]}