Skip to content

Commit

Permalink
Fix broken live coding support in iOS
Browse files Browse the repository at this point in the history
- Revert to react-native 0.13.0 for now
- Use single source root, this seems required for repl
  • Loading branch information
drapanjanas committed Nov 22, 2015
1 parent e290ec3 commit 05d5efa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ Generated project works in iOS and Android devices.
Before getting started, make sure you have the
[required dependencies](#dependencies) installed.

Install [React Native](https://facebook.github.io/react-native/docs/getting-started.html#content) CLI:
```
npm install -g react-native-cli
```

Then, install the CLI using npm:

```
Expand Down Expand Up @@ -71,7 +66,7 @@ in the simulator.
Try this command as an example:

```clojure
(re-frame.core/dispatch [:set-greeting "Hello Native World!"])
(dispatch [:set-greeting "Hello Native World!"])
```

When the REPL connects to the simulator it will print the location of its
Expand Down Expand Up @@ -104,7 +99,7 @@ $ lein cljsbuild auto android
Changes in .cljs files should be reflected in running application.

Current limitation that this will reload whole application meaning the app-db
will be restored to initial state
will be restored to initial state.

The REPL in android is not available... Contributions are welcome.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "re-natal",
"version": "0.1.8",
"version": "0.1.9",
"description": "Bootstrap ClojureScript React Native apps with reagent and re-frame for iOS and Android",
"main": "index.js",
"author": "Artur Girenko <[email protected]>",
Expand Down
39 changes: 25 additions & 14 deletions re-natal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ validNameRx = /^[A-Z][0-9A-Z]*$/i
camelRx = /([a-z])([A-Z])/g
projNameRx = /\$PROJECT_NAME\$/g
projNameHyphRx = /\$PROJECT_NAME_HYPHENATED\$/g
rnVersion = '0.13.0'
rnPackagerPort = 8081
podMinVersion = '0.38.2'
process.title = 're-natal'
sampleCommand = '(re-frame.core/dispatch [:set-greeting "Hello Native World!"])'
sampleCommand = '(dispatch [:set-greeting "Hello Native World!"])'

log = (s, color = 'green') ->
console.log chalk[color] s
Expand Down Expand Up @@ -206,15 +207,11 @@ init = (projName) ->
fs.mkdirSync 'src/cljsjs'
exec "echo '(ns cljsjs.react)' > src/cljsjs/react.cljs"

fs.mkdirSync 'src-android'
fs.mkdirSync "src-android/#{projNameUs}"
fs.mkdirSync "src-android/#{projNameUs}/android"
fs.mkdirSync 'src-ios'
fs.mkdirSync "src-ios/#{projNameUs}"
fs.mkdirSync "src-ios/#{projNameUs}/ios"
fs.mkdirSync "src/#{projNameUs}/android"
fs.mkdirSync "src/#{projNameUs}/ios"

coreAndroidPath = "src-android/#{projNameUs}/android/core.cljs"
coreIosPath = "src-ios/#{projNameUs}/ios/core.cljs"
coreAndroidPath = "src/#{projNameUs}/android/core.cljs"
coreIosPath = "src/#{projNameUs}/ios/core.cljs"

exec "cp #{resources}core-android.cljs #{coreAndroidPath}"
edit coreAndroidPath, [[projNameHyphRx, projNameHyph], [projNameRx, projName]]
Expand All @@ -223,12 +220,26 @@ init = (projName) ->
edit coreIosPath, [[projNameHyphRx, projNameHyph], [projNameRx, projName]]

log 'Creating React Native skeleton'
fs.mkdirSync 'native'
process.chdir 'native'

exec "react-native init #{projName}"

exec "mv #{projName} native"
fs.writeFileSync 'package.json', JSON.stringify
name: projName
version: '0.0.1'
private: true
scripts:
start: 'node_modules/react-native/packager/packager.sh'
dependencies:
'react-native': rnVersion
, null, 2

exec 'npm i'
exec "
node -e
\"process.argv[3]='#{projName}';
require('react-native/local-cli/init')('.', '#{projName}')\"
"

process.chdir 'native'
fs.unlinkSync 'index.android.js'

log 'Installing Pod dependencies'
Expand Down Expand Up @@ -437,7 +448,7 @@ startRepl = (name, autoChoose) ->
:watch-fn
(fn []
(cljs.repl/load-file repl-env
\"src/#{toUnderscored name}/core.cljs\"))
\"src/#{toUnderscored name}/ios/core.cljs\"))
:analyze-path \"src\"))
"""),
cwd: process.cwd()
Expand Down
4 changes: 2 additions & 2 deletions resources/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
[org.omcljs/ambly "0.6.0"]
[re-frame "0.5.0"]]
:plugins [[lein-cljsbuild "1.1.0"]]
:cljsbuild {:builds {:dev {:source-paths ["src" "src-ios"]
:cljsbuild {:builds {:dev {:source-paths ["src"]
:compiler {:output-to "target/out/main.js"
:output-dir "target/out"
:optimizations :none}}
:android {:source-paths ["src" "src-android"]
:android {:source-paths ["src"]
:compiler {:output-to "native/index.android.js"
:output-dir "target/android"
:optimizations :simple}}}})

0 comments on commit 05d5efa

Please sign in to comment.