react-native
react-native copied to clipboard
Fix compatibility issue with 'cp' command in shell script.
Summary:
This change addresses a compatibility issue arising from the use of the macOS-specific -X flag in the cp command withing a shell script called during the npm run ios command.
The -X flag prevents the copying of Extended Attributes and resource forks, which indeed prevents possible issues on macOS. However the flag is not supported by GNU's cp, commonly installed via homebrew on macOS systems, and usually added to the user's PATH.
This fix basically does a feature test to figure out if the -X flag is available, and only uses it is the test is positive.
The intended behavior of not copying Extended Attributes and resources forks is still preserved in the script even if GNU's cp is in the path, as GNU's cp doesn't copy these by default.
In short, the script will behave correctly regardless of the cp version installed, but the script will now be more POSIX compatible.
The fix helps prevent unnecessary debugging time as, in my experience, the source of this error is not always displayed in the output of npm run ios.
As mentioned in:
- https://github.com/facebook/react-native/issues/42112#issuecomment-1922990774
- https://github.com/facebook/react-native/issues/39734#issuecomment-1932644315
Relevant Documentation
Changelog:
[IOS] [FIXED] - Fix compatibility issue with 'cp' command in shell script.
Test Plan:
# with GNU's cp in path
npm run ios
# observe build passing (this is the fix)
# remove GNU's cp from path
npm run ios
# observe build passing (no regression)
Hi @sebastiancarlos!
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!
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 17,885,653 | +4,104 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 21,240,052 | +21 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: 8ff05b5a18db85ab699323d1745a5f17cdc8bf6c Branch: main
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Is there a tmp fix for that?
Looks like this was done already: https://github.com/blakef/react-native/commit/e70076a23409b9a4920e4c6b2d7d3f840e738cc5