From 34d5212f5ca468ec28a2a82097c0f7cf8722739d Mon Sep 17 00:00:00 2001 From: Max Metral Date: Thu, 4 May 2023 07:54:01 -0700 Subject: [PATCH] Fix Flipper by moving FB_SONARKIT_ENABLED to RCTAppDelegate (#37240) Summary: An out-of-the-box react-native init project no longer enables Flipper properly as of 0.72.0-rc1. ## Changelog: [IOS] [FIXED] Fix Flipper by moving podfile modification of preprocessor def `FB_SONARKIT_ENABLED` from React-Core to React-RCTAppDelegate where it is now used. Pull Request resolved: https://github.com/facebook/react-native/pull/37240 Test Plan: Generated an app and verified Flipper cannot see the app. Made the modification and generated another app and verified Flipper now sees it and can enable plugins. Verified that runtime (non-test) use of FB_SONARKIT_ENABLED is limited to Libraries/AppDelegate in this project. Reviewed By: dmytrorykun Differential Revision: D45563282 Pulled By: cipolleschi fbshipit-source-id: d760c5ae123cc7c967b19c6c626801d6db28d052 --- .../scripts/cocoapods/__tests__/flipper-test.rb | 10 +++++++++- packages/react-native/scripts/cocoapods/flipper.rb | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb b/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb index d30b5bc7d98..2c0659ecc4c 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/flipper-test.rb @@ -82,7 +82,7 @@ class FlipperTests < Test::Unit::TestCase assert_equal(config.build_settings['SWIFT_VERSION'], '4.1') end - reactCore_target = installer.target_with_name("React-Core") + reactCore_target = installer.target_with_name("React-RCTAppDelegate") reactCore_target.build_configurations.each do |config| if config.name == 'Debug' || config.name == 'CustomConfig' then assert_equal(config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'], ['$(inherited)', 'FB_SONARKIT_ENABLED=1']) @@ -144,6 +144,14 @@ class FlipperTests < Test::Unit::TestCase BuildConfigurationMock.new("Release", is_debug: false), BuildConfigurationMock.new("CustomConfig", is_debug: true), ] + ), + TargetMock.new( + "React-RCTAppDelegate", + [ + BuildConfigurationMock.new("Debug", is_debug: true), + BuildConfigurationMock.new("Release", is_debug: false), + BuildConfigurationMock.new("CustomConfig", is_debug: true), + ] ) ] ) diff --git a/packages/react-native/scripts/cocoapods/flipper.rb b/packages/react-native/scripts/cocoapods/flipper.rb index 2465a5be891..73371c1df60 100644 --- a/packages/react-native/scripts/cocoapods/flipper.rb +++ b/packages/react-native/scripts/cocoapods/flipper.rb @@ -77,8 +77,8 @@ def flipper_post_install(installer) end end - # Enable flipper for React-Core Debug configuration - if target.name == 'React-Core' + # Enable flipper for React-RCTAppDelegate Debug configuration + if target.name == 'React-RCTAppDelegate' target.build_configurations.each do |config| if config.debug? config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'FB_SONARKIT_ENABLED=1']