How to build and deploy a react-native app from command line?

旧街凉风 提交于 2019-12-03 17:44:17

问题


I'd like to automate the build + deploy of my React-Native app, for example to submit a TestFlight build.

Before submitting the app, I usually do the following:

  1. I run react-native bundle
  2. I switch the build configuration to Release in the schema
  3. I comment out the code relative to jsCodeLocation in AppDelegate.m

Is it possible to write a single command from the Terminal for doing those steps, so that I can then deploy it with an automatization tool, e.g. with fastlane?

So far, I'd just need to automatize the 2nd and the 3rd step.

To change jsCodeLocation I could add a condition, e.g.

#if "<build configuration is release>"
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
#else 
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#end

but i don't know how to reach the build configuration setting.


回答1:


I solved rewriting AppDelegate.m as

#ifdef DEBUG
    jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
#else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

now i can use fastlane to deploy without editing the file.



来源:https://stackoverflow.com/questions/32885433/how-to-build-and-deploy-a-react-native-app-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!