Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): add possibility to add arguments to hermes #37533

Closed
wants to merge 3 commits into from
Closed

feat(ios): add possibility to add arguments to hermes #37533

wants to merge 3 commits into from

Conversation

Thanaen
Copy link

@Thanaen Thanaen commented May 23, 2023

Summary:

Today, someone who wants to use a third-party bundler (like rnx-kit's bundler, for example) can do so by exporting the "BUNDLE_COMMAND" variable in the "Bundle React Native code and images" phase in XCode.

This Pull Request would allow the user to customize the compilation step via hermes, by allowing him to add arguments.
This is already possible on Android, thanks to the "hermesFlag" property (addable in android/app/build.gradle).

In my case, this would allow me to add the "-w" flag to hermes so that the compilation emits less logs (which breaks the archiving when using rnx-kit as a bundler).

Linked issues:
microsoft/rnx-kit#2419
microsoft/rnx-kit#2424

Changelog:

[INTERNAL] [ADDED] - Add possibility to add arguments to hermes on XCode via HERMES_EXTRA_ARGS environment variable

Test Plan:

I tested locally my modification: the arguments added via the environment variable are well transmitted to Hermes, and the compilation always works when no argument is added, or when the variable is not exported in the bundle phase on XCode.

@facebook-github-bot
Copy link
Contributor

Hi @Thanaen!

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!

@analysis-bot
Copy link

analysis-bot commented May 23, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,739,375 -6
android hermes armeabi-v7a 8,050,271 -3
android hermes x86 9,229,564 -5
android hermes x86_64 9,081,394 -3
android jsc arm64-v8a 9,302,720 -4
android jsc armeabi-v7a 8,491,195 -4
android jsc x86 9,363,975 -4
android jsc x86_64 9,619,915 -4

Base commit: 1671247
Branch: main

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 23, 2023
@NickGerleman
Copy link
Contributor

Change makes sense to me but it looks like this ran into a merge conflict.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Thanaen! Thanks for this contribution and for helping us keeping Android and iOS aligned.

Changes looks good to me, just a minor change to make our linters happy.

Out of curiosity, where did you set the -w flag? Did you manually update the Xcode script exporting the $HERMES_EXTRA_ARGS?

packages/react-native/scripts/react-native-xcode.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the quotes!

@cipolleschi
Copy link
Contributor

could you also fix the merge conflicts, please? 🙏

@Thanaen
Copy link
Author

Thanaen commented May 24, 2023

I'll get the conflicts resolved as soon as possible! (I was able to add the suggested changes directly from the GitHub mobile app, but I can't resolve conflicts from the app!)

Out of curiosity, where did you set the -w flag? Did you manually update the Xcode script exporting the $HERMES_EXTRA_ARGS?

To test my modification, I directly modified the "Bundle React Native code" phase in XCode!
(By adding the line export HERMES_EXTRA_ARGS=-w)

Does everything look right to you for the commits and PR messages? I wasn't quite sure what wording to use, I based it on what I usually do!

@cipolleschi
Copy link
Contributor

Everything is right to me. I was curious to understand your use case and how/where you intend export the variables specifically.
I hate that we have all those scripts in Xcode, I would love to move them somewhere else and, perhaps, rewrite them in a different language (maybe JS... Swift for iOS would be even better! :D). So, by knowing better your use case, I could have some more ideas! 😄

@Thanaen
Copy link
Author

Thanaen commented May 24, 2023

My use case is a bit particular: it's simply to solve a bug I encounter when trying to use rnx-kit as a bundler for my application.

When I set up rnx-bundle as a bundle command, I could not create archives of my application because of the problem described here: microsoft/rnx-kit#2424

We found that passing the "-w" parameter to Hermes solved this bug, but I did not find an easy way to pass this parameter to Hermes when archiving an iOS project.
Hence this new environment variable!

I hope I answer your question about my use case!

Maybe we could find a way to share this kind of settings in the future, so we don't have to configure these flags or the bundle command for Android and iOS!

@cipolleschi
Copy link
Contributor

/rebase

@Thanaen Thanaen closed this by deleting the head repository Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants