Skip to content

Commit f666885

Browse files
committed
Iterate on the fix
1 parent c9bd738 commit f666885

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

dev-packages/e2e-tests/cli.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ if (actions.includes('create')) {
189189
env: env,
190190
});
191191

192+
// Clean Pods to ensure CocoaPods reads the patched podspec
193+
if (fs.existsSync(`${appDir}/ios/Pods`)) {
194+
fs.rmSync(`${appDir}/ios/Pods`, { recursive: true });
195+
}
196+
if (fs.existsSync(`${appDir}/ios/Podfile.lock`)) {
197+
fs.rmSync(`${appDir}/ios/Podfile.lock`);
198+
}
199+
192200
if (fs.existsSync(`${appDir}/Gemfile`)) {
193201
execSync(`bundle install`, { stdio: 'inherit', cwd: appDir, env: env });
194202
execSync('bundle exec pod install --repo-update', { stdio: 'inherit', cwd: `${appDir}/ios`, env: env });

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,33 @@ debug.log('Patching react-native-launch-arguments podspec', podspecPath);
5656

5757
if (fs.existsSync(podspecPath)) {
5858
const podspec = fs.readFileSync(podspecPath, 'utf8');
59+
debug.log('Found podspec, checking for React dependency...');
60+
5961
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'");
62+
const hasReactDep = /s\.dependency\s+['"]React['"]/.test(podspec);
63+
const hasReactCoreDep = /s\.dependency\s+['"]React\/Core['"]/.test(podspec);
64+
65+
debug.log(`Podspec status: isPatched=${isPatched}, hasReactDep=${hasReactDep}, hasReactCoreDep=${hasReactCoreDep}`);
66+
67+
if (!isPatched && (hasReactDep || hasReactCoreDep)) {
68+
let patched = podspec;
69+
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+
}
74+
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'");
78+
}
6479

6580
fs.writeFileSync(podspecPath, patched);
6681
debug.log('Patched react-native-launch-arguments podspec successfully!');
67-
} else {
82+
} else if (isPatched) {
6883
debug.log('react-native-launch-arguments podspec is already patched!');
84+
} else {
85+
debug.log('Podspec does not contain React dependency - may use install_modules_dependencies');
6986
}
7087
} else {
7188
debug.log('podspec not found, skipping iOS patch');

0 commit comments

Comments
 (0)