From d24507611de7fefc71286fd54b2c909d98a4bf27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Tue, 1 Oct 2024 07:59:25 -0700 Subject: [PATCH] feat(iOS): expose RCT_NEW_ARCH_ENABLED to Swift (#46749) Summary: This PR exposes `RCT_NEW_ARCH_ENABLED` flag to Swift. It allows you to use conditional compilation: ```swift #if RCT_NEW_ARCH_ENABLED func test() { print("I'm running on new arch!) } #else func test() { print("I'm running on old arch!) } #endif ``` ## Changelog: [IOS] [ADDED] - expose RCT_NEW_ARCH_ENABLED to Swift Pull Request resolved: https://github.com/facebook/react-native/pull/46749 Test Plan: CI Green Reviewed By: cortinico Differential Revision: D63689711 Pulled By: cipolleschi fbshipit-source-id: 706013019571f597d1966ffcf13bd47ba7f29a2d --- packages/react-native/scripts/cocoapods/new_architecture.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/scripts/cocoapods/new_architecture.rb b/packages/react-native/scripts/cocoapods/new_architecture.rb index a4e9b720040..079a6aae54f 100644 --- a/packages/react-native/scripts/cocoapods/new_architecture.rb +++ b/packages/react-native/scripts/cocoapods/new_architecture.rb @@ -99,6 +99,7 @@ class NewArchitectureHelper ReactNativePodsUtils.add_flag_to_map_with_inheritance(current_config, "OTHER_CPLUSPLUSFLAGS", self.computeFlags(new_arch_enabled)) + ReactNativePodsUtils.add_flag_to_map_with_inheritance(current_config, "OTHER_SWIFT_FLAGS", new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "") spec.dependency "React-RCTFabric" # This is for Fabric Component spec.dependency "ReactCodegen"