cljsrn

https://github.com/drapanjanas/re-natal | https://github.com/drapanjanas/re-natal/wiki/FAQ | https://github.com/condense/mercury-app/wiki | https://github.com/seantempesta/expo-cljs-template/ https://www.npmjs.com/package/create-expo-cljs-app
Shako Farhad 2020-04-09T11:25:10.008500Z

Hello! I am not a complete beginner to Clojure, Reagent, Re-frame etc as I have built a few web apps, but I am now trying to get a react native application up and going with re-frame and reagent. I have spent past few days hitting my head on the wall, but I can't get through. Basic re-natal project doesn't work, and I don't know how to get a react native up and running. If anyone has experience with react native and clojurescript and you have some time to help a fellow out, please do. Much appreciated!

dotemacs 2020-04-10T09:24:57.036400Z

What does react-native -h and react-native --version return?

Shako Farhad 2020-04-10T10:56:33.036600Z

Good morning!

Shako Farhad 2020-04-10T10:58:41.036800Z

I uninstalled the react-native-cli. It seems that react-native recommend to use @react-native-community/cli instead as react-native-cli is deprecated. So I will create a new react-native project with that cli and try to recreate what I did already. This recommended cli package contains all the things needed. 🙂

Shako Farhad 2020-04-10T10:59:00.037Z

I will come back to this thread as soon as I have sometrhing to share!

👍 1
Shako Farhad 2020-04-10T21:25:46.040100Z

I have made it all work with the new CLI and it is going great.

Shako Farhad 2020-04-10T21:26:02.040300Z

I have even made it work with the android emulator which didn't work earlier.

Shako Farhad 2020-04-10T21:27:11.040500Z

But the one problem I have now is that the emulator doesn't update in a very certain case. It is very hard to explain. Perhaps I need to make a video or something 😛

Shako Farhad 2020-04-11T01:22:35.040700Z

I have fixed that weird problem as well! I am not 100% sure why, but I needed to elevate my function call to the core.cljs file so that my app hot reloaded correctly with state etc. Otherwise it would just hot reload sometimes and other times it would need a full reload. 😮

dotemacs 2020-04-09T11:33:25.010400Z

Hi, maybe you can describe, in detail, what you’ve done, so that we have something to go on. Because saying “it doesn’t work” it’s not very meaningful

Shako Farhad 2020-04-09T11:50:35.010700Z

I have followed https://github.com/drapanjanas/re-natal guide and made no modifications to at all. Just followed that step by step. I have adoptjdk 8 hotspot installed.

dotemacs 2020-04-09T11:50:55.011200Z

And what happened?

Shako Farhad 2020-04-09T11:51:23.011400Z

dotemacs 2020-04-09T11:54:16.013200Z

Maybe post that as a gist? Slack is reporting that it’s a “bin” file

Shako Farhad 2020-04-09T11:56:45.013600Z

This is the output of running "lein figwheel android" and then going to localhost:3449/figwheel-ws

Shako Farhad 2020-04-09T12:01:08.014Z

This is my java version btw D:\Clojure Projects>java -version openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

fricze 2020-04-09T12:56:19.014900Z

I’d try https://github.com/PEZ/rn-rf-shadow I don’t think you need re-natal

dotemacs 2020-04-09T12:57:28.015200Z

Let him just get bootstrapped with re-natal to make sure that it can work

dotemacs 2020-04-09T12:57:36.015400Z

Then he can decide what to go with

dotemacs 2020-04-09T12:59:00.015600Z

Just to understand @shakof91 you ran:

npm install -g re-natal
re-natal init FutureApp
re-natal use-figwheel
and at this point you brought up your Android emulator?

Shako Farhad 2020-04-09T13:00:23.015800Z

yes, then I ran re-natal use-android-device avd then lein figwheel android then react-native run-android

dotemacs 2020-04-09T13:00:40.016Z

OK, and did you start your Android emulator?

Shako Farhad 2020-04-09T13:01:20.016200Z

Yes, I had it up and running before running lein figwheel android command

dotemacs 2020-04-09T13:04:39.016400Z

This is odd. Let me try to run the same steps to see if I can reproduce it. Mind you, I’m on a different operating system and I see that you’re on Windows…

dotemacs 2020-04-09T13:06:37.016600Z

Let me ask you this, does your lein command behave like it should in the other projects?

Shako Farhad 2020-04-09T13:06:44.016800Z

Yeah, I am on windows. But I have clojure and my web app projects working fine.

dotemacs 2020-04-09T13:06:52.017Z

Great

Shako Farhad 2020-04-09T13:06:53.017200Z

Yes it does. But let me double check

dotemacs 2020-04-09T13:07:27.017400Z

Now look in your app, what does your project.clj look like, does it have this: https://github.com/drapanjanas/re-natal/pull/228/files (NOTE: the extra =)

Shako Farhad 2020-04-09T13:10:19.017600Z

YEs, it is exactly like that.

Shako Farhad 2020-04-09T13:10:47.017800Z

Just started up one of my web apps with lein figwheel and it is working as it should.

Shako Farhad 2020-04-09T13:10:53.018Z

So leiningen works fine it seems.

dotemacs 2020-04-09T13:11:58.018200Z

When you said yes, did you mean, you do have the extra = ?

Shako Farhad 2020-04-09T13:12:11.018400Z

yes, I do have the extra =

Shako Farhad 2020-04-09T13:12:43.018600Z

Ah I shouldn\t I guess

dotemacs 2020-04-09T13:12:54.018800Z

I think that this setting is only relevant for JVMs that are over 8

dotemacs 2020-04-09T13:13:13.019Z

But just in case, I’d remove it, because it shouldn’t be there.

Shako Farhad 2020-04-09T13:14:16.019200Z

Remove the whole line or jsut the =?

dotemacs 2020-04-09T13:14:45.019400Z

I’d modify it to look like the green line in the PR I shared above.

dotemacs 2020-04-09T13:21:10.019600Z

OK, so I followed the steps on macOS and it worked for me, I got the REPL prompt, as expected. There is a little omission in the steps listed in the README. Try this:

npm install -g re-natal
re-natal init FutureApp
cd future-app
yarn (or npm install, whichever one you prefer)
re-natal use-android-device avd
re-natal use-figwheel
Open a second terminal and run: react-native run-android.
Once it completes, go back to the first terminal and run:
lein figwheel android

dotemacs 2020-04-09T13:23:47.019800Z

@shakof91 did that work?

Shako Farhad 2020-04-09T13:38:52.020Z

I got a phone call. Let me get back into it. Sorry about the delay

👍 1
Shako Farhad 2020-04-09T13:48:41.020300Z

the metro server doesnt start up. The emulator just says that it was unable to load scrip and that I need to make sure that metro srver is running.

Shako Farhad 2020-04-09T13:49:01.020500Z

dotemacs 2020-04-09T13:51:11.020900Z

If something works, don’t post the output of that, but do post the output of whatever doesn’t work, preferably as a gist, here: https://gist.github.com/

Shako Farhad 2020-04-09T13:51:41.021100Z

Ah that is the one that didn't work. As it didnt start metro server.

dotemacs 2020-04-09T13:52:00.021400Z

OK, but I didn’t see any errors on it.

dotemacs 2020-04-09T13:52:29.021600Z

Let me ask you this, have you used these tools on Windows before and confirmed that they work outside of ClojureScript ?

dotemacs 2020-04-09T13:52:59.021800Z

As in, you’ve got no problems running all these spinning plates in a vanilla JavaScript setup?

dotemacs 2020-04-09T13:53:32.022Z

I’m asking this, because I’m unfamiliar with Windows, and want to make sure that none of the issues that we’re trying to get to work, can work on Windows.

Shako Farhad 2020-04-09T13:54:26.022200Z

Hmmm yeah. Let me startup a normal react native app.

dotemacs 2020-04-09T13:58:21.022400Z

If you confirm that all is working, what error do you get when you run react-native run-android?

Shako Farhad 2020-04-09T14:05:48.022600Z

Yup works great when I just do react-native init Project cd Project react-native run-android

Shako Farhad 2020-04-09T14:06:06.022800Z

I have the emulator up with the Metro running and it works nicely.

dotemacs 2020-04-09T14:06:42.023Z

OK, so go back to the clojurescript project and report back at what step does Metro break for you and share in a gist the error

Shako Farhad 2020-04-09T14:08:36.023200Z

It is when I run react-native run-android https://gist.github.com/ShakoFarhad/fc1c9872a646164700a3486b8308ebda

dotemacs 2020-04-09T14:09:52.023400Z

So in that gist that you’ve shared, I don’t see the error. All I can see there is that the app was installed on your Pixel_3a_API_R(AVD).

Shako Farhad 2020-04-09T14:10:08.023600Z

My successful attempt with normal react native started the Metro server in another cmd terminal and the run-android command is looping in my original terminal. But when I do the same in re-natal project, the Metro terminal doesnt pop up (It pop ups for 1 milli second and then goes away) and the run-android command doesn't loop.

Shako Farhad 2020-04-09T14:13:20.023800Z

I will try to setup the shadowcljs way as it is a bit closer to the normal react native way. Hope it works!

dotemacs 2020-04-09T14:13:30.024Z

Hmmm, that’s unfortunate. Because I don’t have much to go on and tell you what could be broken exactly… So instead of pursuing this path with re-natal could you try another with a different build tool, using shadow-cljs instead of leiningen ?

Shako Farhad 2020-04-09T14:13:58.024200Z

We are in sync! 😉

dotemacs 2020-04-09T14:14:16.024400Z

Use this repo: https://github.com/thheller/reagent-react-native

Shako Farhad 2020-04-09T17:24:27.024700Z

It works!

dotemacs 2020-04-09T17:24:50.024900Z

The above repo, the shadow-cljs one ?

Shako Farhad 2020-04-09T17:24:52.025100Z

I made some modifications and got latest re-frame and latest reagent to work with it. We have an app!

Shako Farhad 2020-04-09T17:25:01.025300Z

The one you linked. I didn't want to use expo 🙂

dotemacs 2020-04-09T17:25:06.025500Z

Great 🙂

Shako Farhad 2020-04-09T17:25:19.025700Z

It successfully built a release app aswell.

👍 1
Shako Farhad 2020-04-09T17:26:04.026Z

I have not tested on mac and ios yet. For now, connecting the app to my own android phone works flawlessly. But connecting to emulator doesn't work. The app inside the emulator just opens and closes.

dotemacs 2020-04-09T17:26:47.026200Z

Hmmm, not sure what could be the issue there… but react-native works on both platforms with ClojureScript

Shako Farhad 2020-04-09T17:27:15.026400Z

Yeah I will test IOS later. 🙂

👍 1
🙂 1
Shako Farhad 2020-04-09T17:27:45.026800Z

As long as it works on my phone I am fine. Don't know why the emulator is being weird, but I guess the phone is better anyway.

dotemacs 2020-04-09T17:28:48.027Z

I remember reading this once, 10+ years ago, and I can’t find the source any more, that describes mobile development experience: “In a Death Star, shooting ants”

Shako Farhad 2020-04-09T17:29:55.027300Z

Hopefully that deathstar is a compact pocket magnifying glass now 😜

1
Shako Farhad 2020-04-09T19:24:09.027600Z

Dotemacs, you have Mac, right? It seems the "npx react-native run-ios" is not recognized in the repo I am working in. Do you have something like that in your repo? Perhaps you could share how you open a emulator and run the code on mac? I have a macbook pro with cocoapods, java, npm, shadowcljs and leiningen installed.

dotemacs 2020-04-09T19:27:05.028700Z

AFK... but try running the above without the npx in front

Shako Farhad 2020-04-09T19:29:02.028900Z

I did. It is the same response. As if react native doesnt have a run-ios command.

Shako Farhad 2020-04-09T21:47:55.031500Z

I have managed to get the index.js file compiled with shadow-cljs in a react native app. And I have also managed to create a APK with the gradlew command. The react-native run-android command also works great as it starts the app on my phone (but not on emulator). But I do not have a react-native run-ios command. And i do not know how to build an ios app out of the index.js file. Anyone know how to proceed with this? I have a mac with xcode, react-native-cli, npm, cocoapods, leiningen and shadow-cljs installed.