3

recently started working with react native and project requires for apps to be build on server. So the theory is that app could be build on request, which means something, lets call this something react native compiler, needs to be on some server which allows me to do this.

For example, this is the location where is react native compiler is "http://example.com/compile", and you have some settings options and button "compile" on that site, and when you click on button, application compiler starts, and after x seconds android and iphone apps are ready to be downloaded. Is this possible?

user1238762
  • 51
  • 1
  • 3

1 Answers1

0

It is surely possible, although it might be complicated to implement, it all boils down to the level of complexity that you want to achieve (just a build system, an online IDE...).

Each React Native application consists of the JavaScript code and one Android and iOS projects (you can include more platforms through 3rd party efforts, but let's keep it simple). Both the iOS and Android SDKs offer command-line tools for the building functionality. In the case of iOS you have the xcrun command and in Android, the project includes some gradle commands that you can execute. So in general, what you have to do is just execute these commands via your backend when an user requests it.

Essentially what you need is the same kind of setup a Continuous Integration server would, but instead of triggering a build whenever changes are made, the server should build the app on demand, and then send back the result of the compilation to the user. You can read more about CI for React Native here and here, for instance.

Community
  • 1
  • 1
martinarroyo
  • 8,517
  • 3
  • 30
  • 65
  • I need a build system. Everything would be generic for all apps, only thing I need to change in every build is one parametar (for now, more in the future). And that one parametar would be different for every app, functionality and design would differ based on that parametar. – user1238762 Dec 13 '16 at 17:04
  • The good thing about the commands I mentioned is that they are highly parametrizable, so you definitely can do that. In the case of Android you can use environment variables in the grade build files, for example. If you give more details about your setup maybe we can come up with something more specific to your case. – martinarroyo Dec 13 '16 at 19:14
  • At this point, only thing I need to send to reactnative aplication apon building it is a 20 caracter string, let say for example a website url and in the future a string in which are defined application display setting, header style, colors and similer. – user1238762 Dec 27 '16 at 17:34
  • Lets say this is the url "http://example.com/display-data", on this url is a json file from which data will be shown on mobile app, and this file will be different in every app. and this is it, only one paramethar, and obviously it can not be hardcoded. – user1238762 Dec 27 '16 at 17:39
  • If that value is something that you will use in code, why not create a file that stores the it, and have it included in the JS bundle on compilation time? For instance, an empty url.json that gets imported as a module in the rest of the code (maybe you'll have to put a bit of boilerplate for testing purposes so that it doesn't complain when developing). Then, when building, replace its content with something like `{url: 'example.com/display-data/'}`. – martinarroyo Dec 27 '16 at 17:49
  • Application needs to be built on request, and before building it, this value need to be inserted into app. I can't do this manually, it needs to be automatic, because every build will have different data, and apps will be built in balk. – user1238762 Dec 27 '16 at 18:27
  • Sure, just do it in your server. A simple string manipulation will do. Make a copy of the project files for each build to avoid concurrent ones overlapping with each other, but other than that it should be fine. – martinarroyo Dec 27 '16 at 18:32