-
-
Notifications
You must be signed in to change notification settings - Fork 358
Expand file tree
/
Copy pathrn.patch.launch-arguments.js
More file actions
executable file
·90 lines (72 loc) · 3.03 KB
/
rn.patch.launch-arguments.js
File metadata and controls
executable file
·90 lines (72 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { argv } = require('process');
const parseArgs = require('minimist');
const { debug } = require('@sentry/core');
debug.enable();
const args = parseArgs(argv.slice(2));
if (!args['app-dir']) {
throw new Error('Missing --app-dir');
}
const buildGradlePath = path.join(
args['app-dir'],
'node_modules',
'react-native-launch-arguments',
'android',
'build.gradle'
);
debug.log('Patching react-native-launch-arguments build.gradle', buildGradlePath);
if (!fs.existsSync(buildGradlePath)) {
debug.log('build.gradle not found, skipping patch');
} else {
const buildGradle = fs.readFileSync(buildGradlePath, 'utf8');
// Replace destinationDir with destinationDirectory.get() for Gradle 9+ compatibility
const isPatched = buildGradle.includes('destinationDirectory.get()');
if (!isPatched) {
const patched = buildGradle.replace(
/\.destinationDir\b/g,
'.destinationDirectory.get()'
);
fs.writeFileSync(buildGradlePath, patched);
debug.log('Patched react-native-launch-arguments build.gradle successfully!');
} else {
debug.log('react-native-launch-arguments build.gradle is already patched!');
}
}
// Patch iOS podspec for React Native 0.71+ compatibility
// Replace 'React' with 'React-Core' to fix RCTRegisterModule undefined symbol error in RN 0.84+ with dynamic frameworks
const podspecPath = path.join(
args['app-dir'],
'node_modules',
'react-native-launch-arguments',
'react-native-launch-arguments.podspec'
);
debug.log('Patching react-native-launch-arguments podspec', podspecPath);
if (fs.existsSync(podspecPath)) {
const podspec = fs.readFileSync(podspecPath, 'utf8');
debug.log('Found podspec, checking for React dependency...');
const isPatched = podspec.includes("s.dependency 'React-Core'") || podspec.includes('s.dependency "React-Core"');
const hasReactDep = /s\.dependency\s+['"]React['"]/.test(podspec);
const hasReactCoreDep = /s\.dependency\s+['"]React\/Core['"]/.test(podspec);
debug.log(`Podspec status: isPatched=${isPatched}, hasReactDep=${hasReactDep}, hasReactCoreDep=${hasReactCoreDep}`);
if (!isPatched && (hasReactDep || hasReactCoreDep)) {
let patched = podspec;
if (hasReactDep) {
debug.log("Replacing s.dependency 'React' with s.dependency 'React-Core'");
patched = patched.replace(/s\.dependency\s+['"]React['"]/g, "s.dependency 'React-Core'");
}
if (hasReactCoreDep) {
debug.log("Replacing s.dependency 'React/Core' with s.dependency 'React-Core'");
patched = patched.replace(/s\.dependency\s+['"]React\/Core['"]/g, "s.dependency 'React-Core'");
}
fs.writeFileSync(podspecPath, patched);
debug.log('Patched react-native-launch-arguments podspec successfully!');
} else if (isPatched) {
debug.log('react-native-launch-arguments podspec is already patched!');
} else {
debug.log('Podspec does not contain React dependency - may use install_modules_dependencies');
}
} else {
debug.log('podspec not found, skipping iOS patch');
}