react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Allow passing extra arguments in with-environment.sh

Open davidliu opened this issue 2 months ago • 8 comments

Summary:

Addresses #54140.

This allows adding extra arguments when running a command with with-environment.sh.

Changelog:

[IOS|] [CHANGED] - Allow passing extra arguments in with-environment.sh

Test Plan:

Tested by changing the "Bundle React Native code and images" build phase in the ReproducerApp template to execute with an extra argument like so:

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE index.example"

Can observe that the subsequent command picks up the extra argument.

Also tested building normally, without the extra argument, works as expected.

davidliu avatar Oct 16 '25 13:10 davidliu

Hi @davidliu!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

meta-cla[bot] avatar Oct 16 '25 13:10 meta-cla[bot]

Fails
:no_entry_sign:

:clipboard: Verify Changelog Format - See Changelog format

Generated by :no_entry_sign: dangerJS against 335cdf6f46898e0db83a83978c9fbbb7c36460dd

react-native-bot avatar Oct 16 '25 13:10 react-native-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

meta-cla[bot] avatar Oct 17 '25 08:10 meta-cla[bot]

Hi @davidliu thanks for the PR.

There are some security concerns involved in this change. We are not sure that allowing to execute a command with an arbitrary set of arguments is safe.

Can you expand a little bit more on your use case? Why do you need to run the script with extra arguments?

cipolleschi avatar Oct 17 '25 16:10 cipolleschi

Hi @cipolleschi, as outlined in #54140, my personal usecase is for the react-native-xcode.sh script, which can take an extra argument to specify the entry file during the iOS build process. I used it previously so that my index file could be written in typescript and thus would have a filename of index.ts.

It's not a big issue or anything though, just a minor inconvenience. I'm not really knowledgeable about the security issues here, but if there's actual concerns, feel free to close the PR.

davidliu avatar Oct 20 '25 07:10 davidliu

Hi @cipolleschi, as outlined in #54140, my personal usecase is for the react-native-xcode.sh script, which can take an extra argument to specify the entry file during the iOS build process. I used it previously so that my index file could be written in typescript and thus would have a filename of index.ts.

It's not a big issue or anything though, just a minor inconvenience. I'm not really knowledgeable about the security issues here, but if there's actual concerns, feel free to close the PR.

Worth mention that without @davidliu's suggested change I wasn't able to run app on physical devices even being in the same network as described here.

So, I'm not sure what should be the final fix in case this PR get's closed without any other suggested change.

nicolas-rohricht avatar Oct 20 '25 13:10 nicolas-rohricht

Hi!

We would really like to be able to pass arguments to the command. Our use case is with sentry which specifies this in there xcode build phase documentation:

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
SENTRY_XCODE="../node_modules/@sentry/react-native/scripts/sentry-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $SENTRY_XCODE"

where the sentry script sentry-xcode.sh takes and uses an argument like this

REACT_NATIVE_XCODE_DEFAULT="../node_modules/react-native/scripts/react-native-xcode.sh"
REACT_NATIVE_XCODE="${1:-$REACT_NATIVE_XCODE_DEFAULT}"

As we do not use the default path, we would like to specify our own. But, because the argument is not passed to the sentry script the default is used, and we are unable to use sentry without patch.

So in our case passing one argument would be sufficient, we would not need an arbitrary amount

Thanks in advance

simon-thuresson-md avatar Nov 26 '25 15:11 simon-thuresson-md

Hi @cipolleschi

Is there any progress on this? I was just hit by this trying to update RN to 0.81.1. I'm also using Sentry so my problem is probably the same as reported by @simon-thuresson-md here: https://github.com/facebook/react-native/pull/54166#issuecomment-3581858505

jenskuhrjorgensen avatar Dec 15 '25 08:12 jenskuhrjorgensen