From 77e6bff629312f20cdacb1e798cd2464ac50db9e Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 8 Jun 2022 05:58:04 -0700 Subject: [PATCH] Use `GCC_PREPROCESSOR_DEFINITIONS` to set `FB_SONARKIT_ENABLED` (#33972) Summary: `OTHER_CFLAGS` doesn't seem to work when the file is imported from Objc++. This causes flipper to not be included. ## Changelog [iOS] [Fixed] - Use `GCC_PREPROCESSOR_DEFINITIONS` to set `FB_SONARKIT_ENABLED` Pull Request resolved: https://github.com/facebook/react-native/pull/33972 Test Plan: Tested the change in an app. Used a breakpoint to see that flipper code is not executed before this change, and is after. Also made sure other `GCC_PREPROCESSOR_DEFINITIONS` set by cocoapods are still properly inherited. Reviewed By: cipolleschi Differential Revision: D37001624 Pulled By: dmitryrykun fbshipit-source-id: 920f3fe368a9fbe2cde9aa1e6d5b3b883c42119d --- scripts/cocoapods/__tests__/flipper-test.rb | 2 +- scripts/cocoapods/flipper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cocoapods/__tests__/flipper-test.rb b/scripts/cocoapods/__tests__/flipper-test.rb index 60961b8050f0a6..feffeb5c49a6f9 100644 --- a/scripts/cocoapods/__tests__/flipper-test.rb +++ b/scripts/cocoapods/__tests__/flipper-test.rb @@ -86,7 +86,7 @@ def test_postInstall_updatesThePodCorrectly reactCore_target = installer.target_with_name("React-Core") reactCore_target.build_configurations.each do |config| if config.name == 'Debug' then - assert_equal(config.build_settings['OTHER_CFLAGS'], "$(inherited) -DFB_SONARKIT_ENABLED=1") + assert_equal(config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'], ['$(inherited)', 'FB_SONARKIT_ENABLED=1']) else assert_true(config.build_settings.empty?) end diff --git a/scripts/cocoapods/flipper.rb b/scripts/cocoapods/flipper.rb index 676a891e12cb05..4e901fb3a0aad2 100644 --- a/scripts/cocoapods/flipper.rb +++ b/scripts/cocoapods/flipper.rb @@ -84,7 +84,7 @@ def flipper_post_install(installer) if target.name == 'React-Core' target.build_configurations.each do |config| if config.name == 'Debug' - config.build_settings['OTHER_CFLAGS'] = "$(inherited) -DFB_SONARKIT_ENABLED=1" + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'FB_SONARKIT_ENABLED=1'] end end end