Skip to content

Commit

Permalink
adjust how we add/check for existing args in the xcode phase updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Edney committed Jan 30, 2024
1 parent cf998de commit d6f7690
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/react-native-cli/src/lib/Xcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export EXTRA_PACKAGER_ARGS="--sourcemap-output $TMPDIR/$(md5 -qs "$CONFIGURATION
See ${DOCS_LINK} for more information`

const EXTRA_PACKAGER_ARGS = '"$(SRCROOT)/.xcode.env.local",\n"$(SRCROOT)/.xcode.env"'
const EXTRA_PACKAGER_ARGS = ['$(SRCROOT)/.xcode.env.local', '$(SRCROOT)/.xcode.env']

export async function updateXcodeProject (projectRoot: string, endpoint: string|undefined, logger: Logger) {
const iosDir = path.join(projectRoot, 'ios')
Expand Down Expand Up @@ -99,14 +99,14 @@ async function addUploadSourceMapsTask (
return true
}

function addExtraPackagerArgs (phaseId: string, existingShellScript: string, logger: Logger): [string, boolean] {
logger.info(existingShellScript)
const parsedExistingShellScript = JSON.parse(existingShellScript) as string
logger.info(parsedExistingShellScript)
if (parsedExistingShellScript.includes(EXTRA_PACKAGER_ARGS)) {
function addExtraPackagerArgs (phaseId: string, existingInputFiles: string[], logger: Logger): [string[], boolean] {
if (arrayContainsElements(existingInputFiles, EXTRA_PACKAGER_ARGS)) {
logger.warn(`The "Bundle React Native Code and Images" build phase (${phaseId}) already includes the required arguments`)
return [existingShellScript, false]
return [existingInputFiles, false]
}
const scriptLines = parsedExistingShellScript.split('\n')
return [JSON.stringify([EXTRA_PACKAGER_ARGS].concat(scriptLines).join('\n')), true]
return [EXTRA_PACKAGER_ARGS.concat(existingInputFiles), true]
}

function arrayContainsElements (mainArray: any[], subArray: any[]): boolean {
return subArray.every(element => mainArray.some(mainElement => mainElement === element))
}

0 comments on commit d6f7690

Please sign in to comment.