@@ -6,8 +6,8 @@ const { argv } = require('process');
66const xcode = require ( 'xcode' ) ;
77const parseArgs = require ( 'minimist' ) ;
88const semver = require ( 'semver' ) ;
9- const { logger } = require ( '@sentry/core' ) ;
10- logger . enable ( ) ;
9+ const { debug } = require ( '@sentry/core' ) ;
10+ debug . enable ( ) ;
1111
1212const args = parseArgs ( argv . slice ( 2 ) ) ;
1313if ( ! args . project ) {
@@ -17,7 +17,7 @@ if (!args['rn-version']) {
1717 throw new Error ( 'Missing --rn-version' ) ;
1818}
1919
20- logger . info ( 'Patching Xcode project' , args . project , 'for RN version' , args [ 'rn-version' ] ) ;
20+ debug . log ( 'Patching Xcode project' , args . project , 'for RN version' , args [ 'rn-version' ] ) ;
2121
2222const newBundleScriptRNVersion = '0.69.0-rc.0' ;
2323
@@ -29,15 +29,15 @@ const symbolsScript = `
2929` ;
3030const symbolsPatchRegex = / s e n t r y - c l i \s + ( u p l o a d - d s y m | d e b u g - f i l e s u p l o a d ) / ;
3131if ( semver . satisfies ( args [ 'rn-version' ] , `< ${ newBundleScriptRNVersion } ` , { includePrerelease : true } ) ) {
32- logger . info ( 'Applying old bundle script patch' ) ;
32+ debug . log ( 'Applying old bundle script patch' ) ;
3333 bundleScript = `
3434export NODE_BINARY=node
3535../node_modules/@sentry/react-native/scripts/sentry-xcode.sh ../node_modules/react-native/scripts/react-native-xcode.sh
3636` ;
3737 bundleScriptRegex = / ( p a c k a g e r | s c r i p t s ) \/ r e a c t - n a t i v e - x c o d e \. s h \b / ;
3838 bundlePatchRegex = / s e n t r y - c l i \s + r e a c t - n a t i v e [ \s - ] x c o d e / ;
3939} else if ( semver . satisfies ( args [ 'rn-version' ] , `>= ${ newBundleScriptRNVersion } ` , { includePrerelease : true } ) ) {
40- logger . info ( 'Applying new bundle script patch' ) ;
40+ debug . log ( 'Applying new bundle script patch' ) ;
4141 bundleScript = `
4242WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
4343REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
@@ -62,38 +62,32 @@ for (const key in buildPhasesRaw) {
6262 }
6363}
6464
65- buildPhases . forEach ( ( phase ) => {
65+ buildPhases . forEach ( phase => {
6666 const isBundleReactNative = phase . shellScript . match ( bundleScriptRegex ) ;
6767 const isPatched = phase . shellScript . match ( bundlePatchRegex ) ;
6868 if ( ! isBundleReactNative ) {
6969 return ;
7070 }
7171 if ( isPatched ) {
72- logger . warn ( 'Xcode project Bundle RN Build phase already patched' ) ;
72+ debug . warn ( 'Xcode project Bundle RN Build phase already patched' ) ;
7373 return ;
7474 }
7575 phase . shellScript = JSON . stringify ( bundleScript ) ;
76- logger . info ( 'Patched Xcode project Bundle RN Build phase' ) ;
76+ debug . log ( 'Patched Xcode project Bundle RN Build phase' ) ;
7777} ) ;
7878
79- const isSymbolsPhase = ( phase ) => phase . shellScript . match ( symbolsPatchRegex ) ;
79+ const isSymbolsPhase = phase => phase . shellScript . match ( symbolsPatchRegex ) ;
8080const areSymbolsPatched = buildPhases . some ( isSymbolsPhase ) ;
8181
8282if ( ! areSymbolsPatched ) {
83- project . addBuildPhase (
84- [ ] ,
85- 'PBXShellScriptBuildPhase' ,
86- 'Upload Debug Symbols to Sentry' ,
87- null ,
88- {
89- shellPath : '/bin/sh' ,
90- shellScript : symbolsScript ,
91- } ,
92- ) ;
93- logger . info ( 'Added Xcode project Upload Debug Symbols Build phase' ) ;
83+ project . addBuildPhase ( [ ] , 'PBXShellScriptBuildPhase' , 'Upload Debug Symbols to Sentry' , null , {
84+ shellPath : '/bin/sh' ,
85+ shellScript : symbolsScript ,
86+ } ) ;
87+ debug . log ( 'Added Xcode project Upload Debug Symbols Build phase' ) ;
9488} else {
95- logger . warn ( 'Xcode project Upload Debug Symbols Build phase already patched' ) ;
89+ debug . warn ( 'Xcode project Upload Debug Symbols Build phase already patched' ) ;
9690}
9791
9892fs . writeFileSync ( args . project , project . writeSync ( ) ) ;
99- logger . info ( 'Patched Xcode project successfully!' ) ;
93+ debug . log ( 'Patched Xcode project successfully!' ) ;
0 commit comments