Skip to content

Conversation

@atlj
Copy link
Contributor

@atlj atlj commented Jun 14, 2025

Summary

bundleURL on iOS was using Bundle.main to retrieve the main.jsbundle file. Bundle.main returns the Bundle instance of the target that executes the code. This means the generated main.jsbundle file should always be placed at ReactBrownfield framework's bundle for it to work.

This PR makes it possible to change the bundle instance, so the framework target that uses @_exported to reexport rn-brownfield can also own the main.jsbundle file.

Test plan

  1. Compile react-native-brownfield as a framework
  2. Update the bundle insntance to point to a different target
  3. Place your main.jsbundle to that different target
  4. Make sure the js bundle is resolved properly.

@atlj atlj requested a review from Copilot June 14, 2025 21:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables specifying a custom Bundle instance for locating the main.jsbundle on iOS instead of always using Bundle.main.

  • Introduces a bundle property on the delegate defaulting to Bundle.main.
  • Updates sourceURL(for:) to use the customizable bundle.
  • Exposes an @objc public var bundle on ReactNativeBrownfield to override at runtime.
Comments suppressed due to low confidence (3)

ios/ReactNativeBrownfield.swift:62

  • [nitpick] The property name bundle is very generic and shadows the Bundle type; consider renaming it to something like resourceBundle or bundleOverride to improve clarity.
@objc public var bundle: Bundle = Bundle.main {

ios/ReactNativeBrownfield.swift:60

  • The doc comment should mention when and how to set this property (e.g., before initializing the bridge) and what effect it has on bundle resolution.
* Default value: Bundle.main

ios/ReactNativeBrownfield.swift:25

  • Consider adding a unit or integration test to verify that overriding bundle properly resolves resources from a non-main bundle.
return bundle.url(forResource: resourceName, withExtension: fileExtension)

Copy link
Member

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

Can you also update the docs about it? 🙏

@thymikee thymikee requested a review from okwasniewski June 18, 2025 09:00
Copy link
Member

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

Thanks!

@okwasniewski okwasniewski merged commit 07d6a37 into main Jun 18, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants