Skip to content

Commit c9bd738

Browse files
committed
Fix Build RN 0.84.0-rc.0 legacy hermes ios production dynamic
1 parent 2b81c80 commit c9bd738

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

dev-packages/e2e-tests/cli.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ if (actions.includes('create')) {
156156
env: Object.assign(env, { YARN_ENABLE_IMMUTABLE_INSTALLS: false }),
157157
});
158158

159-
// Patch react-native-launch-arguments for Gradle 9+ compatibility
159+
// Patch react-native-launch-arguments for Gradle 9+ compatibility (Android) and React Native 0.84+ compatibility (iOS)
160160
execSync(`${patchScriptsDir}/rn.patch.launch-arguments.js --app-dir .`, {
161161
stdio: 'inherit',
162162
cwd: appDir,

dev-packages/e2e-tests/patch-scripts/rn.patch.launch-arguments.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,49 @@ debug.log('Patching react-native-launch-arguments build.gradle', buildGradlePath
2525

2626
if (!fs.existsSync(buildGradlePath)) {
2727
debug.log('build.gradle not found, skipping patch');
28-
return;
28+
} else {
29+
const buildGradle = fs.readFileSync(buildGradlePath, 'utf8');
30+
31+
// Replace destinationDir with destinationDirectory.get() for Gradle 9+ compatibility
32+
const isPatched = buildGradle.includes('destinationDirectory.get()');
33+
if (!isPatched) {
34+
const patched = buildGradle.replace(
35+
/\.destinationDir\b/g,
36+
'.destinationDirectory.get()'
37+
);
38+
39+
fs.writeFileSync(buildGradlePath, patched);
40+
debug.log('Patched react-native-launch-arguments build.gradle successfully!');
41+
} else {
42+
debug.log('react-native-launch-arguments build.gradle is already patched!');
43+
}
2944
}
3045

31-
const buildGradle = fs.readFileSync(buildGradlePath, 'utf8');
46+
// Patch iOS podspec for React Native 0.71+ compatibility
47+
// Replace 'React' with 'React-Core' to fix RCTRegisterModule undefined symbol error in RN 0.84+ with dynamic frameworks
48+
const podspecPath = path.join(
49+
args['app-dir'],
50+
'node_modules',
51+
'react-native-launch-arguments',
52+
'react-native-launch-arguments.podspec'
53+
);
54+
55+
debug.log('Patching react-native-launch-arguments podspec', podspecPath);
3256

33-
// Replace destinationDir with destinationDirectory.get() for Gradle 9+ compatibility
34-
const isPatched = buildGradle.includes('destinationDirectory.get()');
35-
if (!isPatched) {
36-
const patched = buildGradle.replace(
37-
/\.destinationDir\b/g,
38-
'.destinationDirectory.get()'
39-
);
57+
if (fs.existsSync(podspecPath)) {
58+
const podspec = fs.readFileSync(podspecPath, 'utf8');
59+
const isPatched = podspec.includes("s.dependency 'React-Core'") || podspec.includes('s.dependency "React-Core"');
60+
if (!isPatched) {
61+
const patched = podspec
62+
.replace(/s\.dependency\s+['"]React['"]/g, "s.dependency 'React-Core'")
63+
.replace(/s\.dependency\s+['"]React\/Core['"]/g, "s.dependency 'React-Core'");
4064

41-
fs.writeFileSync(buildGradlePath, patched);
42-
debug.log('Patched react-native-launch-arguments build.gradle successfully!');
65+
fs.writeFileSync(podspecPath, patched);
66+
debug.log('Patched react-native-launch-arguments podspec successfully!');
67+
} else {
68+
debug.log('react-native-launch-arguments podspec is already patched!');
69+
}
4370
} else {
44-
debug.log('react-native-launch-arguments build.gradle is already patched!');
71+
debug.log('podspec not found, skipping iOS patch');
4572
}
4673

0 commit comments

Comments
 (0)