1212# Explicitly enable new architecture
1313ENV [ 'RCT_NEW_ARCH_ENABLED' ] = '1'
1414
15- # Build React Native from source so patch-package changes to native RN code are compiled.
16- ENV [ 'RCT_USE_PREBUILT_RNCORE' ] = '0 '
17- ENV [ 'RCT_USE_RN_DEP' ] = '0 '
15+ # When '0' = Build React Native from source so patch-package changes to native RN code are compiled (if any exist) .
16+ ENV [ 'RCT_USE_PREBUILT_RNCORE' ] = '1 '
17+ ENV [ 'RCT_USE_RN_DEP' ] = '1 '
1818
1919# The JS bundle is compiled compiled using a different version than the prebuilt Hermes engine embedded in the native binary, causing a runtime crash.
2020ENV [ 'RCT_HERMES_V1_ENABLED' ] = '0'
@@ -103,18 +103,6 @@ post_install do |installer|
103103 # :ccache_enabled => true
104104 )
105105
106- installer . pods_project . targets . each do |target |
107- if target . name == 'fmt'
108- target . build_configurations . each do |config |
109- config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] ||= [ '$(inherited)' ]
110- config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] << 'FMT_USE_CONSTEXPR=0'
111- config . build_settings [ 'OTHER_CPLUSPLUSFLAGS' ] ||= [ '$(inherited)' ]
112- config . build_settings [ 'OTHER_CPLUSPLUSFLAGS' ] << '-Wno-invalid-constexpr'
113- config . build_settings [ 'CLANG_CXX_LANGUAGE_STANDARD' ] = 'c++23'
114- end
115- end
116- end
117-
118106 installer . pods_project . build_configurations . each do |config |
119107 config . build_settings [ 'OTHER_LDFLAGS' ] ||= [ '$(inherited)' ]
120108 if config . name == "Debug"
@@ -124,10 +112,11 @@ post_install do |installer|
124112
125113 installer . pods_project . targets . each do |target |
126114 target . build_configurations . each do |config |
127- if target . name == "React"
128- if config . name == "ReleaseDevApp"
129- config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] ||= [ ]
130- config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] |= [ '$(inherited)' , "DEBUG=1" ]
115+ if config . name == "ReleaseDevApp"
116+ config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] ||= [ ]
117+ config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] |= [ '$(inherited)' , 'NDEBUG=1' , 'REACT_NATIVE_DEBUG=1' ]
118+ if target . name . start_with? ( "React" ) || target . name . start_with? ( "RCT" )
119+ config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] |= [ 'DEBUG=1' ]
131120 end
132121 end
133122
@@ -141,9 +130,20 @@ post_install do |installer|
141130 # target that includes it, we define NDEBUG for ALL targets to set
142131 # folly::kIsDebug=false, disabling the assertion. This matches the
143132 # behavior of Release/Production builds which already define NDEBUG.
133+ #
134+ # However, NDEBUG also triggers flags.h to define REACT_NATIVE_PRODUCTION
135+ # instead of REACT_NATIVE_DEBUG, which changes the layout of the Sealable
136+ # base class (adds std::atomic<bool> in debug mode). The prebuilt RN
137+ # binaries were compiled with REACT_NATIVE_DEBUG active (no NDEBUG), so
138+ # their Props/ViewProps structs are larger. Third-party Fabric components
139+ # (e.g. react-native-safe-area-context) compiled with NDEBUG=1 would see
140+ # a smaller ViewProps, causing an ABI mismatch and EXC_BAD_ACCESS.
141+ # Fix: explicitly define REACT_NATIVE_DEBUG=1 so flags.h skips its
142+ # NDEBUG-based auto-detection, keeping the Sealable debug layout and
143+ # matching the prebuilt ABI, while NDEBUG still silences Folly.
144144 if config . name == 'Debug'
145145 config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] ||= [ ]
146- config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] |= [ '$(inherited)' , 'NDEBUG=1' ]
146+ config . build_settings [ 'GCC_PREPROCESSOR_DEFINITIONS' ] |= [ '$(inherited)' , 'NDEBUG=1' , 'REACT_NATIVE_DEBUG=1' ]
147147 end
148148
149149 end
0 commit comments