-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Documentation missing instructions for running on device via static bundle #240
Comments
Thanks man, I was wondering why it wouldn't run. For anyone else seeking an answer to "Could not connect to development server" look here. |
Worth noting, (at least unless I am missing something) if you go down this path, you will have to run the curl step, every time. If you want to see your changes. |
I dug around and got all the way to the last step before I had to start sifting through issues, thanks for outlining the steps, now it can actually find the bundle file 👍 |
Just noting here, nothing is requiring you to run a node server, could also just serve a static bundle. Could also make the URL a debug app setting. |
Thanks! |
Does this mean that we can host the whole bundle on a remote nodejs server, and always load the bundle (the react part) over http from the client? This would be great to deploy new features without having to rebuild the ios app. Is this realistic or doesn't Apple allow dynamic app functionality like that? |
As far as I know, this is impossible, Apple doesn't allow this. |
https://www.meteor.com/blog/2014/10/02/Apple-hot-code-push-mobile This could be great if we could update all our React logic dynamically without the clients having to be updated. |
It'd be great to verify whether a remote hosted bundle would work or not. It seems like it should work, you ship one version with the app, and save/update the local bundle based on some remote bundle. Updates to any wrapped native modules would still require an app store update though. |
Awesome- thank you! |
FYI. The instructions are "available" @ https://github.com/facebook/react-native/blob/master/Examples/SampleApp/iOS/AppDelegate.m#L31 But I def had to add the step:
|
Nevermind, I realized I didn't add in the main.jsbundle referenced here: http://stackoverflow.com/questions/29374410/how-to-build-react-native-app-for-iphone/29468098#29468098 |
Still getting the same error even after doing what was referenced in stackoverflow in my last post. Thoughts? |
Summary: This helps generating offline bundles by adding almost empty main.jsbundle to the app. The only thing left is to fetch minified bundle from server and save it to the file, then flip the switch in AppDelegate. I'll add docs about this soon. facebook#240 Test Plan: Did the `curl` command from comments. Changed URL to be local file, started SampleApp, works fine without server.
@brentvatne this works! many thanks 👍 |
on your app dir run react-native bundle --minify |
@brentvatne works great for me also. Thanks 👍 |
@brentvatne thanks for the issue ... followed the instructions and seems that the curl requests needs to be
have you seen this before ... can't figure out what might be causing it Also made a SO question that has more specific info ... though no answer yet http://stackoverflow.com/questions/34187094/react-native-ios-loading-from-pre-budled-file-fails |
Another issue not discussed in this thread which can also cause the "Could not connect to development server" error is App Transport Security (ATS) in iOS9. This should be mentioned in the instructions as well. Cf. http://stackoverflow.com/a/34880394/2397068 |
@satya164 In my perspective the document is still confusing about I tried both the method mentioned above and also the
|
@kainliu AFAIK the bundle is automatically generated while generating the package. |
@satya164 is right, we now have a special script integrated into the build process that does this for you (see #3545 (comment)). @kainliu the problem with your command line is that it won't work for images, i.e. if you are using |
@brentvatne thanks a bunch! You saved a whole lot of time! :) |
I'm doing this with a pre-existing swift codebase. Using |
HI @brentvatne! in appdelegate.m jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; Btw I get one issue. |
this shit does not work .. constantly. - No bundle on anything, It shows locally and in Product the Bundle is there. |
Currently (
Then build the app and you can run it in your device. |
Thanks creeperyang! You save my time. |
I have a issue! |
Thanks creeperyang, I can't quite believe that we have to do that to get it working, but it works. |
With
Or better: |
@creeperyang How do I keep it updated everytime. Once the bundle is created, it never changes. Even after making small changes in index.ios.js, it doesn't get reflected in main.jsbundle. How to automate that ? |
If anyone wants to improve on these instructions and add them to the docs, feel free, I can do it later if nobody else jumps on it - I just wanted to document it somewhere for now.
iOS/AppDelegate.m
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
npm start
and then runcurl http://localhost:8081/index.ios.bundle -o main.jsbundle
- if this fails (as it did on my machine) add the--ipv4
flag to the end of it.Add Files to "Project Name Here"
- choose themain.jsbundle
file that you generated.You can now run the app on a device (either via usb or TestFlight) without needing to have a server running.
The text was updated successfully, but these errors were encountered: