Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best folder structure to build two twin apps with React Native?

I need to create two twin apps with React Native and both apps will be 90% the same they will use some shared components and the styles will be different.

the question is : should i create one react native project and from there to building two apps

and the folder structure will be :

  • ReactProject
    • shared
    • project1
      • components
    • project2
      • components
  • index.ios.js
  • index.android.js

and when I want to build one of the apps I will need to change the main component.

or should I create to different React Native projects

and the folder structure will be :

  • shared
  • ReactProject1
    • components
    • index.ios.js
    • index.android.js
  • ReactProject2
    • components
    • index.ios.js
    • index.android.js

I would like to know what is the right approach to do this kind of project

thanks !

like image 844
Eran Abir Avatar asked May 24 '17 07:05

Eran Abir


1 Answers

This is absolutely a personal preference as stated in comments. One could easily increase the number of structure options beyond 2. Other than that I can share my experience on this.

We build an app, actually 4 (quadruplets), from a single react native project. We choose that way because our apps had to be highly similar. They share same functionality. Furthermore, when one has more than one of these apps installed on their device they can easily switch between apps via deep linking. However they differ on the theme colors, logos, names and backend services to call etc. One of the ways to create multiple apps from a single project is to rename the project. But you can still produce multiple apps while keeping the project name same. Then you need to change some project files accordingly. These files are, for iOS;

  • Info.plist
  • project.pbxproj
  • AppDelegate.m

For Android;

  • strings.xml
  • MainActivity.java
  • MainApplicatoin.java
  • AndroidManifest.xml
  • android/build.gradle
  • app/build.gradle

Actually changing all these files manually is an error-prone and cumbersome action. So that in order to manage these changes we wrote a bash script that converts a base app to the version that we want. Using this approach we can manage 8 apps (quadruplets for iOS and Android) from a single project repo. In the end we are really happy about using React Native which let us build 8 production quality native apps in 3 months without knowing native app development at production level.

like image 82
milkersarac Avatar answered Sep 20 '22 22:09

milkersarac