Skip to content

iOS: Add new configuration for RCTDevMenu - #53505

Closed
coado wants to merge 1 commit into
react:mainfrom
coado:dev-menu
Closed

coado wants to merge 1 commit into
react:mainfrom
coado:dev-menu

Conversation

@coado

@coado coado commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Summary:

Following the RFC, this PR adds new RCTDevMenu configuration and extends RCTReactNativeFactory API for passing it to the particular RCTHost. The RCTDevMenuConfiguration includes:

  • devMenuEnabled,
  • shakeGestureEnabled,
  • keyboardShortcutsEnabled

Changelog:

[IOS][ADDED] - Add new configuration for RCTDevMenu

Test Plan:

Tested with different configurations on RCTDevMenuConfiguration:

Click to view code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.reactNativeFactory = [[RCTReactNativeFactory alloc] initWithDelegate:self];
#if USE_OSS_CODEGEN
  self.dependencyProvider = [RCTAppDependencyProvider new];
#endif
  
  RCTDevMenuConfiguration *devMenuConfiguration = [[RCTDevMenuConfiguration alloc] initWithDevMenuEnabled:true shakeGestureEnabled:false keyboardShortcutsEnabled:false];

  [self.reactNativeFactory setDevMenuConfiguration:devMenuConfiguration];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

  [self.reactNativeFactory startReactNativeWithModuleName:@"RNTesterApp"
                                                 inWindow:self.window
                                        initialProperties:[self prepareInitialProps]
                                            launchOptions:launchOptions];

  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

  return YES;
}

Run helloworld:

hello-world-screenshot

@meta-cla meta-cla 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 Aug 28, 2025
@facebook-github-bot facebook-github-bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Aug 28, 2025
@Saadnajmi

Saadnajmi commented Aug 29, 2025 •

Copy link
Copy Markdown
Contributor

A diff we have internally at Microsoft is we expose RCTDevSetting's dataSource (which is private, but seems like it was meant to be public?) so that we can set our own custom one, which sets whether the dev menu is shown and other settings that way. I was considering upstreaming that change when I noticed this PR. Food for thought in case it's helpful / you wanna go that way.

See these two:
https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.h#L47 and https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.mm#L57

@coado

coado commented Aug 29, 2025

Copy link
Copy Markdown
Contributor Author

A diff we have internally at Microsoft is we expose RCTDevSetting's dataSource (which is private, but seems like it was meant to be public?) so that we can set our own custom one, which sets whether the dev menu is shown and other settings that way. I was considering upstreaming that change when I noticed this PR. Food for thought in case it's helpful / you wanna go that way.

See these two:

https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.h#L47

and
https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.mm#L57

Hey, thanks for the suggestion. I think exposing RCTDevSettingsDataSource might be a bit out of scope for us. You can learn more about the changes we plan to make in RFC.

@Saadnajmi

Copy link
Copy Markdown
Contributor

A diff we have internally at Microsoft is we expose RCTDevSetting's dataSource (which is private, but seems like it was meant to be public?) so that we can set our own custom one, which sets whether the dev menu is shown and other settings that way. I was considering upstreaming that change when I noticed this PR. Food for thought in case it's helpful / you wanna go that way.

See these two:

https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.h#L47

and

https://github.com/facebook/react-native/blob/b02251e7f5c147296fab93c1ae613d27400cec92/packages/react-native/React/CoreModules/RCTDevSettings.mm#L57

Hey, thanks for the suggestion. I think exposing RCTDevSettingsDataSource might be a bit out of scope for us. You can learn more about the changes we plan to make in RFC.

Ah, didn't see the RFC :) thanks!

Comment thread packages/rn-tester/RNTester/AppDelegate.mm Outdated
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has imported this pull request. If you are a Meta employee, you can view this in D81684275.

@coado
coado marked this pull request as ready for review September 4, 2025 15:10
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has imported this pull request. If you are a Meta employee, you can view this in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has imported this pull request. If you are a Meta employee, you can view this in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has imported this pull request. If you are a Meta employee, you can view this in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

2 similar comments
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

Summary:
Following the [RFC](react-native-community/discussions-and-proposals#925), this PR adds new `RCTDevMenu` configuration  and extends `RCTReactNativeFactory` API for passing it to the particular `RCTHost`.  The `RCTDevMenuConfiguration` includes:

- isDevMenuEnabled,
- isShakeGestureEnabled,
- areKeyboardShortcutsEnabled



## Changelog:

[IOS][ADDED] - Add new configuration for `RCTDevMenu` 

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests


Test Plan:
Tested with different configurations on `RCTDevMenuConfiguration`:

<details>
<summary>Click to view code</summary>

```objc
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.reactNativeFactory = [[RCTReactNativeFactory alloc] initWithDelegate:self];
#if USE_OSS_CODEGEN
  self.dependencyProvider = [RCTAppDependencyProvider new];
#endif
  
  RCTDevMenuConfiguration *devMenuConfiguration = [[RCTDevMenuConfiguration alloc] initWithDevMenuEnabled:true shakeGestureEnabled:false keyboardShortcutsEnabled:false];

  [self.reactNativeFactory setDevMenuConfiguration:devMenuConfiguration];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

  [self.reactNativeFactory startReactNativeWithModuleName:@"RNTesterApp"
                                                 inWindow:self.window
                                        initialProperties:[self prepareInitialProps]
                                            launchOptions:launchOptions];

  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

  return YES;
}
```

</details>

Run helloworld: 

<img src="https://github.com/user-attachments/assets/16c35176-6fbe-498c-96fd-a0fe988a5e3c" alt="hello-world-screenshot" width="300">

Differential Revision: D81684275

Pulled By: coado
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado has exported this pull request. If you are a Meta employee, you can view the originating diff in D81684275.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @coado in 29d5aa5

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 1, 2025
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@coado merged this pull request in 29d5aa5.

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. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants