react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.66k stars 126 forks source link

Provide an easy way to install CocoaPods excluding Flipper (for release/CI) #312

Open brentvatne opened 3 years ago

brentvatne commented 3 years ago

Introduction

I noticed that iOS release builds became a lot slower since React Native 0.62, and it turns out that a lot of this can be explained by Flipper. By leaving Flipper out, I was able to see a ~50% reduction in build time on a simple project on my local machine and similar results on CI.

Local build times

A brand new app, with yarn ios --configuration Release on a Macbook Pro with 2.4 GHz 8-Core Intel Core i9:

(ymmv depending on project complexity and other factors, of course)

CI build times

In a less powerful environment (Intel(R) Xeon(R) CPU E5-2697 with 6 cores available to VM), the same project had the following build times:

Details

It would be convenient to have some mechanism to exclude Flipper from CocoaPods when running pod install. We could wire up our build scripts locally and on CI to run, eg: pod install --production or pod install --release, or set and environment variable (SKIP_FLIPPER=1 pod install). The flag option seems preferable, but listed both anyways.

This could also be useful as a standard for other dependencies that the community builds in order to assist with development.

Discussion points

An aside

We should probably update the conditional include directives in the React Native template so they work in debug if Flipper is not installed. This works well for me:

#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
rickhanlonii commented 3 years ago

Cosign, I thought that this is how it was working when we added it.

I'm not sure what the best way to dot his is (maybe @fkgozali @alloy @orta or @thymikee know)

retyui commented 3 years ago

Just exclude Flipper from Podfile (is a ruby file)

image

https://github.com/facebook/flipper/issues/1326#issuecomment-788223247