From 0c442bf4b186859a0262ef259ba70d4996da3f3f Mon Sep 17 00:00:00 2001 From: Mohammed Abdel Raouf Date: Thu, 2 Mar 2023 10:07:52 -0800 Subject: [PATCH] Fix searching for FlipperClient.h headers in productions builds if PRODUCTION=1 passed (#4275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: In newer builds of react-native if you passed parameters PRODUCTION=1, flipper pods won't get installed you can see that in their codebase here [react_native_pods.rb](https://github.com/facebook/react-native/blob/6a43fafd78d581f63c664b9af6d10828ac7f77fa/scripts/react_native_pods.rb#L140) so when building ios `react-native-flipper` set `compiler_flags = '-DFB_SONARKIT_ENABLED=1'` in the podspec file which initializeFlipper and lead to the following error: `node_modules/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h:12:9: 'FlipperKit/FlipperClient.h' file not found` ## Changelog use same condition as react-native to wrap `s.compiler_flags = compiler_flags` and conditionally pass `compiler_flags = '-DFB_SONARKIT_ENABLED=1'` to compiler_flags to avoid build problems Pull Request resolved: https://github.com/facebook/flipper/pull/4275 Test Plan: To reproduce - create new react-native app - install react-native-flipper `yarn add react-native-flipper` - run `env PRODUCTION=1 npx pod-install ` - run `yarn ios` Before patch: ```sh node_modules/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h:12:9: 'FlipperKit/FlipperClient.h' file not found ``` After patch: ```sh ▸ Build Succeeded success Successfully built the app ``` Reviewed By: jknoxville Differential Revision: D41298345 Pulled By: mweststrate fbshipit-source-id: fb46772d46b8105fccb1abb673502bca428eea1d --- .../react-native-flipper/react-native-flipper.podspec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/react-native/react-native-flipper/react-native-flipper.podspec b/react-native/react-native-flipper/react-native-flipper.podspec index a8b591af0..f76436e22 100644 --- a/react-native/react-native-flipper/react-native-flipper.podspec +++ b/react-native/react-native-flipper/react-native-flipper.podspec @@ -25,6 +25,10 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/Headers/Public/FlipperKit\"" } s.requires_arc = true - s.compiler_flags = compiler_flags + if ENV['PRODUCTION'] == '1' + Pod::UI.puts "#{s.name}: Found PRODUCTION=1, #{s.name} will be disabled for production builds" + else + s.compiler_flags = compiler_flags + end s.dependency "React-Core" end