@@ -25,22 +25,49 @@ debug.log('Patching react-native-launch-arguments build.gradle', buildGradlePath
2525
2626if ( ! 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+ / \. d e s t i n a t i o n D i r \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- / \. d e s t i n a t i o n D i r \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 \. d e p e n d e n c y \s + [ ' " ] R e a c t [ ' " ] / g , "s.dependency 'React-Core'" )
63+ . replace ( / s \. d e p e n d e n c y \s + [ ' " ] R e a c t \/ C o r e [ ' " ] / 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