使用React Native构建两个双胞胎应用程序的最佳文件夹结构是什么? [英] What is the best folder structure to build two twin apps with React Native?

查看:99
本文介绍了使用React Native构建两个双胞胎应用程序的最佳文件夹结构是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用React Native创建两个双胞胎应用程序,并且两个应用程序将使用相同的共享组件90%相同,并且样式将有所不同。

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.

问题是:我应该创建一个React Native项目,然后从那里创建两个应用程序

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

,文件夹结构将是:


  • ReactProject


    • 共享

    • project1


      • 组件


      • 组件

      当我要构建其中一个应用程序时,我需要进行更改

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

      ,或者我应该为其他React Native项目创建

      or should I create to different React Native projects

      ,文件夹结构为:


      • 共享

      • ReactProject1


        • 组件

        • index.ios.js

        • index.android.js

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

          • 组件

          • index.ios.js

          • index.android.js

          我想知道什么是进行此类项目的正确方法

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

          谢谢!

          推荐答案

          如评论中所述,这绝对是个人喜好。可以很容易地将结构选项的数量增加到2个以上。除此之外,我可以分享我的经验。

          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.

          我们从以下位置构建了一个应用程序,实际上是4个(四元组)一个反应本地项目。我们之所以选择这种方式,是因为我们的应用必须高度相似。它们共享相同的功能。此外,当一个设备上安装了多个这些应用程序时,他们可以通过深层链接轻松地在这些应用程序之间切换。但是,它们在主题颜色,徽标,名称和要调用的后端服务等方面有所不同。从单个项目创建多个应用程序的一种方法是重命名该项目。但是您仍然可以在保持项目名称不变的情况下生产多个应用程序。然后,您需要相应地更改一些项目文件。这些文件适用于iOS;

          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

          对于Android;

          For Android;


          • strings.xml

          • MainActivity.java

          • MainApplicatoin.java

          • AndroidManifest.xml

          • android / build.gradle

          • app / build.gradle

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

          实际上手动更改所有这些文件是容易出错和繁琐的操作。为了管理这些更改,我们编写了一个bash脚本,将基本应用程序转换为所需的版本。使用这种方法,我们可以从单个项目存储库中管理8个应用程序(iOS和Android的四元组)。最后,我们对使用React Native感到非常高兴,它使我们能够在3个月内构建8个具有生产质量的本地应用程序,而无需了解生产级别的本地应用程序开发。

          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.

          这篇关于使用React Native构建两个双胞胎应用程序的最佳文件夹结构是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆