-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any app (incl. default example) crashes with "Can't find variable: React" when launched from a JS bundle on an iOS device #32
Comments
Hi, thanks for reporting. Reproduced it on iOS and Android using reagent and on-next interfaces
I am almost sure I check the steps above before each release, but now surprise, this does not work! Latest changes in re-natal were only in figwheel-bridge.js which is not used at all in case of 'lein prod-build'. But, I could find still working version of luno-react-native app on my local drive (tar.gz is too big to upload here) I have uploaded it to temp storage in the internets: luno-react-native.tar.gz
To reproduce the problem:
This makes me think tat recent NPM cleanup has sometheing to to with this |
OK, I am confused, but seems I have found the solution.The problems seems to be with the global variable assignment: (set! js/React (js/require "react-native")) which compiles into (which is expected): React=require("react-native"); But, I guess that now some kind of validation is in place to forbid global assigments like that, huh? So, the solution/workaround is: (set! js/window.React (js/require "react-native")) Instead of @gnl can you check and confirm that this workaround works also for you? |
Fix confirmed, thank you! |
...but works just fine when the JS is compiled+delivered via Figwheel/React Native packager.
Screenshot:
![img_0003](https://cloud.githubusercontent.com/assets/1690961/14063278/b641182c-f3ca-11e5-82d9-285a63d57867.jpg)
...and Xcode console log:
I'm attaching the main.jsbundle:
main.jsbundle.zip
A readable one can be created with:
Steps to reproduce:
Make sure the JS is delivered from a bundle by editing ios/CrashingApp/AppDelegate.m, commenting this line:
and uncommenting this one:
Connect device, select it as launch destination in Xcode and hit the run button (after the prod-build process in step 1 is complete).
Expected: app launches after a brief display of a "loading from bundle" status message.
Observed: App crashes with aforementioned exception.
The app works fine on a device and in the simulator when run with:
(+ reverse step 2 above to disable the bundle).
re-natal version is 0.2.28.
This issue seems like it might be related:
este/este#752
My guess is that the JS compiled with ":optimizations :simple" (as in the default config of the prod-build profile) somehow trips up some optimization/transformation the react native packager does to the JS when creating a bundle.
I tried switching the prod-build leiningen profile to :optimizations :none (as in the working figwheel profile configuration), but then the bundle cannot be created at all, the process dying with the following message:
Either way, this should work with the default configuration, as it most definitely used to. I'm not quite sure when it stopped, since I was happily developing with Figwheel for more than a week until I tried creating a standalone package to deploy to a device and saw this happen.
Oddly enough, even when downgrading re-natal to 0.2.26 (which I'm pretty sure I used for my last successful packaging) and init-ing a new default project I observe the same behaviour, so not sure which part of the build chain is causing this exactly.
In the same environment, creating a standard RN project with
react-native init DemoApp
and running on a device from a JS bundle works just fine.Can anyone else reproduce this?
Thanks!
The text was updated successfully, but these errors were encountered: