@@ -56,16 +56,33 @@ debug.log('Patching react-native-launch-arguments podspec', podspecPath);
5656
5757if ( 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 \. 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'" ) ;
62+ const hasReactDep = / s \. d e p e n d e n c y \s + [ ' " ] R e a c t [ ' " ] / . test ( podspec ) ;
63+ const hasReactCoreDep = / s \. d e p e n d e n c y \s + [ ' " ] R e a c t \/ C o r e [ ' " ] / . 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 \. d e p e n d e n c y \s + [ ' " ] R e a c t [ ' " ] / 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 \. 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'" ) ;
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