Should I use React Native for iOS development?

foreword

React Native is Facebook's open source Javascript framework in 2015, which aims to use Javascript to efficiently develop mobile apps. Combined with several obvious advantages and Facebook's powerful propaganda machine, it immediately became a star development framework for companies large and small at home and abroad. The passion for participation in the open source community and the publicity of various blogs are evident from the 56,000+ stars and 13,000+ Fork on its Github.

When it comes to React Native, the iOS developer community is also mixed. Some people think that React Native is faster and better, that Apple's native set will be finished, and it will be too late to learn it soon; some people think that React Native is just another toy of Facebook, and it is still difficult to understand the native Swift/Objective- C poses a sufficient threat.

The author hopes to put forward my own views on this issue based on my experience in developing React Native and native iOS in the past few years, as well as what I have seen and heard in Silicon Valley. For a new technology, I personally think that there are two criteria for judging whether it is worth adopting:

  • Whether the technology itself has enough advantages
  • Does the technology meet current development needs?

Let's talk about React Native from the perspective of technology and development requirements.

Technical Features of React Native

The advantages of React Native are obvious. The prominent position of the official website has a brief introduction, and the developers have also made relevant explanations on various occasions. The summary is as follows:

  • Cross-platform development . The same piece of Javascript code can be used for both iOS and Android platforms. Compared with the previous iOS and Android apps that maintain a set of code with similar logic, the development, testing and maintenance costs of React Native are much lower.

  • Compile quickly . Compared with the long compilation in Xcode, React Native adopts the hot reload (Hot Reload) real-time compilation mechanism, which greatly improves the development experience of App UI, and almost reaches the same effect as web development.

  • Post quickly . Through JSBundle, React Native can instantly update the App. Compared with the original lengthy review and upload process, the efficiency of publishing and testing new features has been greatly improved.

  • Rendering and layout are more efficient. React Native can directly apply the CSS and flex mechanism of web development, get rid of the tedious mathematical calculations in autolayout and frame layout, and is more direct and convenient.

  • Simple and easy to learn . Compared with the complex knowledge system of iOS and Android, React Native is essentially a state machine, which is not difficult for developers to understand, and the actual operation can be described as easy to get started and easy to use. If you are a front-end developer, then you have a corresponding understanding of Javascript, and developing mobile applications with React Native is a matter of course.

The cross-platform nature of React Native is the biggest selling point

Of course, React Native, which looks perfect, also has many technical risks, such as:

  • Third-party dependencies . React Native relies heavily on Facebook for maintenance. Every technical update and policy change of Apple on iOS will affect the original React Native code base, and waiting for Facebook and the community to fix will hinder App updates and user experience. Some time ago, Baidu and developers abandoned
    React Native and forced Facebook to modify the developer license (License) incident, which proved that the risk of relying on third parties for development does exist.

  • logical overhead. Until today, React Native is still only version 0.49, which only supports simple UI production. Its immature API is difficult to achieve even complex animations, not to mention the underlying optimization and compatible operations of iOS. At the same time, because of different operating systems and devices, React Native has to deal with them separately, which is another challenge to the maintenance of the code base.

  • Difficulty in coordinating . The introduction of React Native to native iOS and Android apps will increase the complexity of the entire code base, and it is also difficult to debug the underlying native code. It can be said that the cost of development and maintenance has increased.

Also, there are many people who feel that React Native's performance is not as good as native Objective-C/Swift. I've tried it myself, and I don't think there's much difference. From the communication with many developers in Silicon Valley, it is known that the performance of React Native is only milliseconds worse than the native one, and it will not affect the user experience at all. Friends who are interested in this can read this articleComparing the Performance between Native iOS (Swift) and React-Native . The article compares multiple APIs in the three dimensions of CPU, GPU, and memory. React Native is similar to native Swift. More than really.

The performance of React Native on UI is really amazing

App development needs

As an iOS developer, talking about technology apart from the application is like the flower in the mirror and the moon in the water - it's just empty talk. In actual App development, there are the following situations. Let's analyze whether it is suitable to introduce React Native one by one.

In the first case, develop a simple app from scratch. It's likely to be a nibble for an indie developer, or a first-generation product for a startup. I personally think React Native is a good fit for this situation. At this point, the UI and business logic of the App are relatively simple, and React Native can satisfy most situations. Moreover, developers have limited time and do not have time to systematically learn the knowledge systems of the two platforms; startups have limited costs and need to release products on both iOS and Android platforms in order to quickly accumulate the first wave of users in the shortest time and at the lowest cost. to investment. The technical features of React Native fit these requirements very well.

A product that fits this profile is Facebook's F8 app, an app built for its annual developer conference. Because it only has simple functions such as calendar, map, push, etc., React Native is perfect - it took 1 engineer 2 weeks to complete all the development, and it is now open source on Github.

In the second case, develop a more complex App from scratch. This may be a new product line for a company, or it may be a refactoring of a mature app. In this case, quality, word of mouth, and future maintenance are the primary considerations. Native Swift/Objective-C solutions are more mature and diverse when facing practical problems, and React Native cannot exert its technical advantages, so native development is A more secure choice.

For example, Uber launched their new app last year. I also tried React Native internally, but due to the inability to meet the needs of the App for complex animations, the lack of compatibility with the underlying system, and the lack of performance optimization, I finally decided to give up its use.

Facebook F8 App, a classic case of React Native

In the third case, new functions are introduced into the original App. This situation is more complicated, and it is divided into the following situations:

  1. The original App codebase is 100% Objective-C/Swift. In this case, I personally do not recommend introducing React Native. Because the technical team has been stabilized on the two technology stacks of iOS and Android, the introduction of the third technology stack will increase the technical complexity and maintenance costs. In terms of personnel, a new React Native team needs to be formed, both in terms of expenses and organizational structure. Negative impact. Unless there is enough budget, or there is a plan to adopt React Native significantly later, it is not recommended to introduce React Native.

  2. Verify that new features should be introduced . There is a time cost for the company during the verification process, and the top executives hope that decisions can be made in the short term. React Native is the silver bullet for this situation. As far as I know Tesla's App uses this mechanism.

  3. New functions are definitely introduced, not core functions, and not complicated. In this case, you can certainly try React Native. If it is a web-end type of app or function, such as Taobao, Ctrip, JD.com, etc., they themselves have a lot of web-end development experience, it is better to let the responsible front-end engineer directly handle the relevant mobile-end business. Even if it is unsuccessful, it will not affect the main business, and it can provide valuable experience for the company's technology accumulation. The main apps of Facebook and Instagram are currently using a similar step-by-step strategy of adopting React Native for some small functions.

  4. New features are definitely introduced, are important features, and have strict release requirements and dates. This is the same as the second case mentioned above, and React Native is not recommended for insurance and safety.

Summarize

From a purely technical point of view, React Native is definitely a rare and excellent framework on the mobile side. The idea of ​​its state machine can be used for reference to write native View Controller, and its UI layout mechanism also provides inspiration for our daily performance optimization.

At present, Silicon Valley generally holds a conservative attitude towards React Native
. The only technology giants that use React Native are Facebook, Amazon, Uber, and Airbnb, and they are all used by small functions and small apps. The good news is that Facebook has spared no effort in React Native, and developers in the circle are also quite positive about it. For more details, read the official development schedule: React Native Scheduling

The author believes that React Native can only play a huge advantage under the consideration of rapid development and cost saving. For iOS developers, React Native can only be used as an appropriate supplement. We should still study more about Swift / Objective-C and App development ideas, which are the key to advanced growth.



Author: So Yin Daochang

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939613&siteId=291194637