Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow compile times with react-native iOS app

I am currently working on a react-native iOS app. While developing I noticed that the compile times for the app are really slow. I got a CI hooked up which roughly does the following:

  • clean git checkout of the applications workspace
  • run unit tests
  • run UI tests build the app

Since this is a clean checkout the app always recompiles all of the react static libraries which come with the React.xcodeproj like libyoga.a, libReact.a, etc. This means that a clean CI build roughly takes ~8min only to build all of the react dependencies (~4min * 2 because the UI test target rebuilds React again).

I wondered whether it would be possible to speed up the compile times. I came up with the following idea but need your advice to tell me if it would work or if I am on the wrong track.

  • Compile all static libraries for iphoneos and iphonesimulator
  • Put them together in a single file via lipo
  • Move them to a folder
  • Put that folder into version control
  • Link the libraries in that folder into the Xcode project

This way it would only be necessary to build a new set of static libraries if I update the react-native version in the package.json, right ?

Another idea which came to my mind is to build a dynamic framework of react-native. The framework could be build only once and then added to the application via carthage or manually. The dynamic framework would link all the react static libraries and add the correct headers to the header search paths.

Does anyone can give me a hint if this could work or has an idea how to improve the build architecture in order to speed up the compile time ?

like image 566
dehlen Avatar asked Mar 22 '18 19:03

dehlen


People also ask

How do I make React Native compile faster?

Build only one ABI during development (Android-only)​ This should reduce your build time by a ~75% factor. If you're using the React Native CLI, you can use the --active-arch-only flag together with the run-android command.

Why is my React Native app slow?

Memory leakage, a React Native performance issue, may occur due to unnecessary processes that run in the background in an Android app. Try using scrolling lists like SectionList, FlatList, or VirtualList, instead of ListView.

Is React Native slower than Swift?

Faster developing. React Native is powered with JavaScript. Thus, up to 90% of the code for your mobile app may be taken from web applications. Building iOS apps with React Native is 33% faster than Swift and takes 1,5 months.


1 Answers

Check these two checkbox 1 Show environment variables in build log 2 Run script only when installing enter image description here

but when you run first time then uncheck it because this load script for first time otherwise you can not open get loading script in packager.

like image 187
Ankit Sharma Avatar answered Oct 02 '22 23:10

Ankit Sharma