Skip to content

Commit 7162526

Browse files
antonisclaude
andcommitted
fix(e2e): Use install_modules_dependencies for react-native-launch-arguments
Enhances the patch script to use install_modules_dependencies() instead of hardcoded React/React-Core dependencies. This is the modern approach for React Native 0.60+ that properly handles all framework configurations (static, dynamic, etc.) and automatically resolves the correct React Native dependencies. This should fix the "Undefined symbols: _RCTRegisterModule" error when building RN 0.84.0 with dynamic frameworks on iOS. The patch now uses the same defensive pattern as RNSentry.podspec, with a fallback to React-Core for older RN versions that don't have install_modules_dependencies defined. Tested locally and verified: - Patch successfully replaces s.dependency "React" - Generated Ruby syntax is valid - Idempotent (safe to run multiple times) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fed421b commit 7162526

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (!fs.existsSync(buildGradlePath)) {
4444
}
4545

4646
// 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
47+
// Replace 'React' with install_modules_dependencies() to fix RCTRegisterModule undefined symbol error in RN 0.84+ with dynamic frameworks
4848
const podspecPath = path.join(
4949
args['app-dir'],
5050
'node_modules',
@@ -58,31 +58,44 @@ if (fs.existsSync(podspecPath)) {
5858
const podspec = fs.readFileSync(podspecPath, 'utf8');
5959
debug.log('Found podspec, checking for React dependency...');
6060

61-
const isPatched = podspec.includes("s.dependency 'React-Core'") || podspec.includes('s.dependency "React-Core"');
61+
// Check if already patched with install_modules_dependencies
62+
const isPatched = podspec.includes('install_modules_dependencies');
6263
const hasReactDep = /s\.dependency\s+['"]React['"]/.test(podspec);
6364
const hasReactCoreDep = /s\.dependency\s+['"]React\/Core['"]/.test(podspec);
65+
const hasReactCoreDepOnly = podspec.includes("s.dependency 'React-Core'") || podspec.includes('s.dependency "React-Core"');
6466

65-
debug.log(`Podspec status: isPatched=${isPatched}, hasReactDep=${hasReactDep}, hasReactCoreDep=${hasReactCoreDep}`);
67+
debug.log(`Podspec status: isPatched=${isPatched}, hasReactDep=${hasReactDep}, hasReactCoreDep=${hasReactCoreDep}, hasReactCoreDepOnly=${hasReactCoreDepOnly}`);
6668

67-
if (!isPatched && (hasReactDep || hasReactCoreDep)) {
69+
if (!isPatched && (hasReactDep || hasReactCoreDep || hasReactCoreDepOnly)) {
6870
let patched = podspec;
6971

70-
if (hasReactDep) {
71-
debug.log("Replacing s.dependency 'React' with s.dependency 'React-Core'");
72-
patched = patched.replace(/s\.dependency\s+['"]React['"]/g, "s.dependency 'React-Core'");
73-
}
72+
// Replace any React dependency with install_modules_dependencies(s)
73+
// This is the modern approach that works with all framework configurations (static, dynamic, etc.)
74+
// and automatically includes the correct React Native dependencies
75+
const installModulesDepsBlock = `
76+
if defined? install_modules_dependencies
77+
install_modules_dependencies(s)
78+
else
79+
s.dependency "React-Core"
80+
end`;
7481

75-
if (hasReactCoreDep) {
76-
debug.log("Replacing s.dependency 'React/Core' with s.dependency 'React-Core'");
77-
patched = patched.replace(/s\.dependency\s+['"]React\/Core['"]/g, "s.dependency 'React-Core'");
82+
if (hasReactDep) {
83+
debug.log("Replacing s.dependency 'React' with install_modules_dependencies(s)");
84+
patched = patched.replace(/\s+s\.dependency\s+['"]React['"]\s*\n/g, installModulesDepsBlock + '\n');
85+
} else if (hasReactCoreDep) {
86+
debug.log("Replacing s.dependency 'React/Core' with install_modules_dependencies(s)");
87+
patched = patched.replace(/\s+s\.dependency\s+['"]React\/Core['"]\s*\n/g, installModulesDepsBlock + '\n');
88+
} else if (hasReactCoreDepOnly) {
89+
debug.log("Replacing s.dependency 'React-Core' with install_modules_dependencies(s)");
90+
patched = patched.replace(/\s+s\.dependency\s+['"]React-Core['"]\s*\n/g, installModulesDepsBlock + '\n');
7891
}
7992

8093
fs.writeFileSync(podspecPath, patched);
8194
debug.log('Patched react-native-launch-arguments podspec successfully!');
8295
} else if (isPatched) {
8396
debug.log('react-native-launch-arguments podspec is already patched!');
8497
} else {
85-
debug.log('Podspec does not contain React dependency - may use install_modules_dependencies');
98+
debug.log('Podspec does not contain React dependency - may already use install_modules_dependencies');
8699
}
87100
} else {
88101
debug.log('podspec not found, skipping iOS patch');

0 commit comments

Comments
 (0)