SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

iOS: Add new `RCTCustomBundleConfiguration` for modifying bundle URL (#54006)

Summary:
## Summary:

Following the [RFC](https://github.com/react-native-community/discussions-and-proposals/pull/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`.

Pull Request resolved: https://github.com/facebook/react-native/pull/54006

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

Reviewed By: cipolleschi

Differential Revision: D84058022

Pulled By: coado

fbshipit-source-id: 62c24ec5c6b089220ef9b78add487dcd65aaac9e
D
Dawid Malecki committed
6fa75cce48f4f3dc631c181a25a9401a2bf88eeb
Parent: c7a6935
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com> on 11/4/2025, 1:19:59 PM