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

Introducing RCT_DEV_KEY_COMMANDS to disable RCTKeyCommands #46692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

343max
Copy link

@343max 343max commented Sep 27, 2024

Summary:

Right now it's not possible to distribute a development build with RCT_DEV enabled via TestFlight. This is unfortunate because distribution via TestFlight can help smaller teams using React Native to develop and test on devices much easier.

Development Builds are rejected by Apple because they use Private API which isn't allowed. I looked into this issue and the only place where private API is in RCTKeyCommands. Once RCTKeyCommands are disabled like in a production build it's very straight forward to use TestFlight for Development Build distribution.

As test devices often don't have physical keyboards anyways most developers probably will happily give up on keyboard shortcuts for device development builds if they can distribute via TestFlight.

Out of the box this change doesn't change the behavior at all. The user can change the behavior by changing RCT_DEV_KEY_COMMANDS=0 in the precompiler macros.

Changelog:

[IOS] [ADDED] - Added RCT_DEV_KEY_COMMANDS to optionally remove RCTKeyCommands from Development Builds

Test Plan:

build an React Native Development build to see nothing has changed.
build a build with RCT_DEV_KEY_COMMANDS=0 to see how the Development Build still builds and works fine but now allows you to submit to TestFlight.

@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 Sep 27, 2024
@343max 343max changed the title custom macro to disable RCTKeyCommands Introducing RCT_DEV_KEY_COMMANDS to disable RCTKeyCommands Sep 27, 2024
@343max 343max marked this pull request as ready for review September 27, 2024 12:58
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 27, 2024
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.

@343max Thanks for the PR.
Where does users have to set the RCT_DEV_KEY_COMMANDS, if they want to disable the Private API?
Should they add the definition manually before this snippet?

I'm a bit confused as we always had that piece of code and we had no report so far of this being a problem.

@343max
Copy link
Author

343max commented Sep 27, 2024

You can do it eg. in Xcode in the Preprocessor Macros.
image

This problem did exist forever. You can find a short discussion about it for example here.

I guess this problem doesn't pop up more often because most devs have different workflows right now: they develop on a machine with Xcode installed and then deploy directly to their phones. Or they can't make it work and therefore never develop directly on their phones but only in the simulator and therefore aren't able to fix a bug when it can't be reproduced in the simulator. (I know, because I've been the only person with native development experience in multiple RN teams and had to fix these issues many many times). This change allows a new deployment workflow for teams working on RN apps that simply wasn't possible before.

@cipolleschi
Copy link
Contributor

@343max could you point out which APIs are private? We are wondering whether this can be implemented without using them, so that there is no need to add another preprocessor macro which is hard to explain to every user.

@343max
Copy link
Author

343max commented Oct 2, 2024

@cipolleschi Here are the selectors the App Store was complaining about last time I tried to do this: _isKeyDown, _modifiedInput, _modifierFlags.

@343max
Copy link
Author

343max commented Oct 17, 2024

If it helps: RCT_DEV_KEY_COMMANDS is completely optional, by default the app will build exactly like before. It only needs to be set if the dev actually wants to deploy the dev build app through TestFlight.

I can also change this PR to use the public API UIKeyCommand instead. I simply didn't do it because I wanted to have my code as few side effects as possible.

@cipolleschi
Copy link
Contributor

@343max Thanks for the ping and I apologize for the delay.

I haven't had the time to properly investigate the thing. We discussed the proposal of using RCT_DEV_KEY_COMMANDS but we would rather not add a new compiler flag if possible.

If you could give it a shot and modify the PR using the public API UIKeyCommand that would be gold and a solution that has more chances to be imported and landed.

Thank you so much for your patience!

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants