Skip to content

iOS: Add new RCTBundleConfiguration for modifying bundle URL#54006

Closed
coado wants to merge 1 commit into
react:mainfrom
coado:bundle-url-ios
Closed

iOS: Add new RCTBundleConfiguration for modifying bundle URL#54006
coado wants to merge 1 commit into
react:mainfrom
coado:bundle-url-ios

Conversation

@coado

@coado coado commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Summary:

Following the RFC, this PR introduces a new RCTBundleConfiguration interface for modifying the bundle URL and exposes a new API for setting its instance in the RCTReactNativeFactory. The configuration object includes:

  • bundleFilePath - the URL of the bundle to load from the file system,
  • packagerServerScheme - the server scheme (e.g. http or https) to use when loading from the packager,
  • packagerServerHost - the server host (e.g. localhost) to use when loading from the packager.

The RCTBundleConfiguration allows only for either bundleFilePath or (packagerServerScheme, packagerServerHost) to be set by defining appropriate initializers.

The logic for creating bundle URL query items is extracted to a separate createJSBundleURLQuery method and is used by RCTBundleManager to set the configured packagerServerHost and packagerServerScheme. If the configuration is not defined, the getBundleURL method returns the result of the passed fallbackURLProvider.

The bundleFilePath should be created with [NSURL fileURLWithPath:<path>], as otherwise the HMR client is created and fails ungracefully. The check is added in the getBundle method to log the error beforehand:

Simulator Screenshot - iPhone 16 Pro - 2025-10-15 at 17 09 58

When the bundleFilePath is set in the RCTBundleConfiguration the Connect to Metro... message shouldn't be suggested.

Changelog:

[IOS][ADDED] - Add new RCTBundleConfiguration for modifying bundle URL on RCTReactNativeFactory.

Test Plan

Test plan included in the last diff in the stack.

@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 Oct 1, 2025
@facebook-github-bot facebook-github-bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Oct 1, 2025
@meta-codesync

meta-codesync Bot commented Oct 7, 2025

Copy link
Copy Markdown

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

@meta-codesync

meta-codesync Bot commented Oct 15, 2025

Copy link
Copy Markdown

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

@coado coado force-pushed the bundle-url-ios branch 2 times, most recently from c904e49 to 8da150a Compare October 20, 2025 13:23
@coado coado marked this pull request as ready for review October 20, 2025 13:59
@coado coado force-pushed the bundle-url-ios branch 2 times, most recently from d871bb8 to 0ef00fd Compare October 24, 2025 07:49
@coado coado changed the title iOS: Add new RCTCustomBundleConfiguration for modifying bundle URL iOS: Add new RCTBundleConfiguration for modifying bundle URL Oct 24, 2025
coado added a commit to coado/react-native that referenced this pull request Oct 28, 2025
…eact#54006)

Summary:
## Summary:

Following the [RFC](react-native-community/discussions-and-proposals#933), this PR introduces a new `RCTBundleConfiguration` interface for modifying the bundle URL and exposes a new API for setting its instance in the `RCTReactNativeFactory`. The configuration object includes:

- bundleFilePath - the URL of the bundle to load from the file system,
- packagerServerScheme - the server scheme (e.g. http or https) to use when loading from the packager,
- packagerServerHost - the server host (e.g. localhost) to use when loading from the packager.

The `RCTBundleConfiguration` allows only for either `bundleFilePath` or `(packagerServerScheme, packagerServerHost)` to be set by defining appropriate initializers. 

The logic for creating bundle URL query items is extracted to a separate `createJSBundleURLQuery` method and is used by `RCTBundleManager` to set the configured `packagerServerHost` and `packagerServerScheme`. If the configuration is not defined, the `getBundleURL` method returns the result of the passed `fallbackURLProvider`.

The `bundleFilePath` should be created with `[NSURL fileURLWithPath:<path>]`, as otherwise the HMR client is created and fails ungracefully. The check is added in the `getBundle` method to log the error beforehand:

<img width="306" height="822" alt="Simulator Screenshot - iPhone 16 Pro - 2025-10-15 at 17 09 58" src="https://github.com/user-attachments/assets/869eed16-c5d8-4204-81d7-bd9cd42b2223" />

When the `bundleFilePath` is set in the `RCTBundleConfiguration` the `Connect to Metro...` message shouldn't be suggested.

## Changelog:

[IOS][ADDED] - Add new `RCTBundleConfiguration` for modifying bundle URL on `RCTReactNativeFactory`.


Test Plan: Test plan included in the last diff in the stack.

Differential Revision: D84058022

Pulled By: coado
…eact#54006)

Summary:
## Summary:

Following the [RFC](react-native-community/discussions-and-proposals#933), this PR introduces a new `RCTBundleConfiguration` interface for modifying the bundle URL and exposes a new API for setting its instance in the `RCTReactNativeFactory`. The configuration object includes:

- bundleFilePath - the URL of the bundle to load from the file system,
- packagerServerScheme - the server scheme (e.g. http or https) to use when loading from the packager,
- packagerServerHost - the server host (e.g. localhost) to use when loading from the packager.

The `RCTBundleConfiguration` allows only for either `bundleFilePath` or `(packagerServerScheme, packagerServerHost)` to be set by defining appropriate initializers. 

The logic for creating bundle URL query items is extracted to a separate `createJSBundleURLQuery` method and is used by `RCTBundleManager` to set the configured `packagerServerHost` and `packagerServerScheme`. If the configuration is not defined, the `getBundleURL` method returns the result of the passed `fallbackURLProvider`.

The `bundleFilePath` should be created with `[NSURL fileURLWithPath:<path>]`, as otherwise the HMR client is created and fails ungracefully. The check is added in the `getBundle` method to log the error beforehand:

<img width="306" height="822" alt="Simulator Screenshot - iPhone 16 Pro - 2025-10-15 at 17 09 58" src="https://github.com/user-attachments/assets/869eed16-c5d8-4204-81d7-bd9cd42b2223" />

When the `bundleFilePath` is set in the `RCTBundleConfiguration` the `Connect to Metro...` message shouldn't be suggested.

## Changelog:

[IOS][ADDED] - Add new `RCTBundleConfiguration` for modifying bundle URL on `RCTReactNativeFactory`.


Test Plan: Test plan included in the last diff in the stack.

Differential Revision: D84058022

Pulled By: coado
coado added a commit to coado/react-native that referenced this pull request Nov 4, 2025
…eact#54006)

Summary:
## Summary:

Following the [RFC](react-native-community/discussions-and-proposals#933), this PR introduces a new `RCTBundleConfiguration` interface for modifying the bundle URL and exposes a new API for setting its instance in the `RCTReactNativeFactory`. The configuration object includes:

- bundleFilePath - the URL of the bundle to load from the file system,
- packagerServerScheme - the server scheme (e.g. http or https) to use when loading from the packager,
- packagerServerHost - the server host (e.g. localhost) to use when loading from the packager.

The `RCTBundleConfiguration` allows only for either `bundleFilePath` or `(packagerServerScheme, packagerServerHost)` to be set by defining appropriate initializers. 

The logic for creating bundle URL query items is extracted to a separate `createJSBundleURLQuery` method and is used by `RCTBundleManager` to set the configured `packagerServerHost` and `packagerServerScheme`. If the configuration is not defined, the `getBundleURL` method returns the result of the passed `fallbackURLProvider`.

The `bundleFilePath` should be created with `[NSURL fileURLWithPath:<path>]`, as otherwise the HMR client is created and fails ungracefully. The check is added in the `getBundle` method to log the error beforehand:

<img width="306" height="822" alt="Simulator Screenshot - iPhone 16 Pro - 2025-10-15 at 17 09 58" src="https://github.com/user-attachments/assets/869eed16-c5d8-4204-81d7-bd9cd42b2223" />

When the `bundleFilePath` is set in the `RCTBundleConfiguration` the `Connect to Metro...` message shouldn't be suggested.

## Changelog:

[IOS][ADDED] - Add new `RCTBundleConfiguration` for modifying bundle URL on `RCTReactNativeFactory`.


Test Plan: Test plan included in the last diff in the stack.

Reviewed By: cipolleschi

Differential Revision: D84058022

Pulled By: coado
@meta-codesync meta-codesync Bot closed this in 6fa75cc Nov 4, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Nov 4, 2025
@meta-codesync

meta-codesync Bot commented Nov 4, 2025

Copy link
Copy Markdown

@coado merged this pull request in 6fa75cc.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @coado in 6fa75cc

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

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.

3 participants