Fix searching for FlipperClient.h headers in productions builds if PRODUCTION=1 passed (#4275)

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](6a43fafd78/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
This commit is contained in:
Mohammed Abdel Raouf
2023-03-02 10:07:52 -08:00
committed by Facebook GitHub Bot
parent fa987e466c
commit 0c442bf4b1

View File

@@ -25,6 +25,10 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,swift}" s.source_files = "ios/**/*.{h,m,swift}"
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/Headers/Public/FlipperKit\"" } s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/Headers/Public/FlipperKit\"" }
s.requires_arc = true s.requires_arc = true
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 s.compiler_flags = compiler_flags
end
s.dependency "React-Core" s.dependency "React-Core"
end end