Skip to content

Commit f411f13

Browse files
authored
Merge pull request #1247 from mendix/moo/MOO-2278-refactor-patches
[MOO-2278] - Refactor react-native patch
2 parents 97af9af + 37a5063 commit f411f13

6 files changed

Lines changed: 444 additions & 1449 deletions

File tree

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
android:largeHeap="true"
6161
android:theme="@style/AppTheme"
6262
android:requestLegacyExternalStorage="true"
63+
android:enableOnBackInvokedCallback="true"
6364
tools:ignore="GoogleAppIndexingWarning">
6465
<activity
6566
android:name="com.mendix.nativetemplate.MainActivity"

android/settings.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
google()
5+
mavenCentral()
6+
}
7+
includeBuild("../node_modules/@react-native/gradle-plugin")
8+
}
29
plugins { id("com.facebook.react.settings") }
310
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
411

ios/Podfile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ end
1212
# Explicitly enable new architecture
1313
ENV['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.
2020
ENV['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

Comments
 (0)