2015-08-26 03:51:24 +00:00
|
|
|
# Natal
|
2015-08-30 04:01:40 +00:00
|
|
|
### Bootstrap ClojureScript-based React Native apps
|
|
|
|
[Dan Motzenbecker](http://oxism.com), MIT License
|
|
|
|
[@dcmotz](https://twitter.com/dcmotz)
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
Natal is a simple command-line utility that automates most of the process of
|
|
|
|
setting up a React Native app running on ClojureScript.
|
|
|
|
|
|
|
|
It stands firmly on the shoulders of giants, specifically those of
|
|
|
|
[Mike Fikes](http://blog.fikesfarm.com) who created
|
|
|
|
[Ambly](https://github.com/omcljs/ambly) and the
|
|
|
|
[documentation](https://github.com/omcljs/ambly/wiki/ClojureScript-React-Native-Quick-Start)
|
|
|
|
on setting up a ClojureScript React Native app.
|
|
|
|
|
2015-08-30 04:02:14 +00:00
|
|
|
|
|
|
|
## Usage
|
2015-08-31 02:03:00 +00:00
|
|
|
|
|
|
|
Before getting started, make sure you have npm, Leiningen, and CocoaPods (>=0.36.4)
|
|
|
|
installed.
|
|
|
|
|
|
|
|
Then, install the CLI using npm:
|
2015-08-30 04:02:14 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
$ npm install -g natal
|
|
|
|
```
|
|
|
|
|
|
|
|
Then run `natal` with your app's name as the first argument:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ natal FutureApp
|
|
|
|
```
|
|
|
|
|
|
|
|
If your app is more than a single word, be sure to type it in CamelCase.
|
|
|
|
A corresponding hyphenated Clojure namespace will be created.
|
|
|
|
|
2015-08-31 02:03:00 +00:00
|
|
|
When Xcode appears, click the play button (or ⌘-R) to run the app on the simulator.
|
2015-08-30 04:16:58 +00:00
|
|
|
|
|
|
|
Then run the following for an interactive workflow:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cd future-app
|
|
|
|
$ ./start.sh
|
|
|
|
```
|
|
|
|
|
2015-08-30 15:35:17 +00:00
|
|
|
First, choose the correct device (probably `[1]`). At the REPL prompt type this:
|
2015-08-30 04:16:58 +00:00
|
|
|
|
|
|
|
```clojure
|
|
|
|
(in-ns 'future-app.core)
|
|
|
|
```
|
|
|
|
|
|
|
|
Changes you make via the REPL or by changing your .cljs files should appear live.
|
|
|
|
|
|
|
|
Try this command as an example:
|
|
|
|
|
|
|
|
```clojure
|
|
|
|
(swap! app-state assoc :text "Hello Native World")
|
|
|
|
```
|
|
|
|
|
2015-08-30 04:21:00 +00:00
|
|
|
When the REPL starts it will print the location of its compilation log.
|
|
|
|
It's useful to tail it to see any errors, like so:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ tail -f /Volumes/Ambly-81C53995/watch.log
|
|
|
|
```
|
|
|
|
|
2015-08-30 04:16:58 +00:00
|
|
|
|
2015-08-30 04:02:33 +00:00
|
|
|
## Tips
|
|
|
|
- Having `rlwrap` installed is optional but recommended since it makes the REPL
|
|
|
|
a much nicer experience with arrow keys
|
|
|
|
- Don't press ⌘-R in the simulator; code changes should be reflected automatically.
|
2015-08-30 04:17:12 +00:00
|
|
|
See [this issue](https://github.com/omcljs/ambly/issues/97) in Ambly for details
|
2015-08-30 04:02:33 +00:00
|
|
|
- Running multiple React Native apps at once can cause problems
|
|
|
|
|
2015-08-30 04:02:51 +00:00
|
|
|
|
|
|
|
## Aspirations
|
2015-08-30 04:17:12 +00:00
|
|
|
- [ ] Automatic wrapping of all React Native component functions for ClojureScript
|
2015-08-30 04:02:51 +00:00
|
|
|
- [ ] Xcode-free development with CLI tools
|
|
|
|
- [ ] Automatically run React packager in background
|
|
|
|
- [ ] Automatically tail cljs build log and report compile errors
|
|
|
|
- [ ] Templates for other ClojureScript React wrappers
|
|
|
|
|
|
|
|
|
|
|
|
Contributions are welcome.
|