-
Notifications
You must be signed in to change notification settings - Fork 36
feat(ios): support bundled JS in debug builds #317
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
base: main
Are you sure you want to change the base?
Changes from all commits
f1b5447
ff2a8a7
c57e753
5967c3e
50e9b91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@callstack/react-native-brownfield': minor | ||
| --- | ||
|
|
||
| Add an opt-in iOS Debug mode for loading the embedded JavaScript bundle with `preferBundledBundleInDebug`, fix `bundleURLOverride` fallback behavior when the override returns `nil`, and add native bundle-resolution tests. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,3 +82,4 @@ secring.gpg | |
|
|
||
| # Typescript | ||
| **/*.tsbuildinfo | ||
| packages/react-native-brownfield/ios/.build/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ ReactNativeBrownfield.shared | |
| | `entryFile` | `String` | `index` | Path to JavaScript entry file in development. | | ||
| | `bundlePath` | `String` | `main.jsbundle` | Path to JavaScript bundle file. | | ||
| | `bundle` | `Bundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. | | ||
| | `preferBundledBundleInDebug` | `Bool` | `false` | Prefer the embedded JavaScript bundle instead of Metro when the framework is built in Debug. | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| | `bundleURLOverride` | `(() -> URL?)?` | `nil` | Dynamic bundle URL provider called on every bundle load. When set, overrides default behavior. | | ||
|
|
||
| --- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,14 @@ When running in **Debug**, React Native Brownfield expects a JS dev server runni | |
| npx react-native start | ||
| ``` | ||
|
|
||
| If you want to run a **Debug-built** framework without Metro, enable the bundled bundle explicitly before calling `startReactNative`: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add a |
||
|
|
||
| ```swift | ||
| ReactNativeBrownfield.shared.bundle = ReactNativeBundle | ||
| ReactNativeBrownfield.shared.preferBundledBundleInDebug = true | ||
| ReactNativeBrownfield.shared.startReactNative() | ||
| ``` | ||
|
|
||
| ### Release Configuration | ||
|
|
||
| In **Release**, the JS bundle is loaded directly from the XCFramework - no dev server needed. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| package com.callstack.nativebrownfieldnavigation | ||
|
|
||
| interface BrownfieldNavigationDelegate | ||
| interface BrownfieldNavigationDelegate { | ||
| fun navigateToSettings() | ||
| fun navigateToReferrals(userId: String) | ||
| } | ||
|
Comment on lines
+3
to
+6
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is codegen-ed and should not be committed :) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,19 @@ | ||
| package com.callstack.nativebrownfieldnavigation | ||
|
|
||
| import android.util.Log | ||
| import com.facebook.react.bridge.ReactApplicationContext | ||
| import com.facebook.react.bridge.ReactMethod | ||
|
|
||
| class NativeBrownfieldNavigationModule( | ||
| reactContext: ReactApplicationContext | ||
| ) : NativeBrownfieldNavigationSpec(reactContext) { | ||
| @ReactMethod | ||
| override fun temporary() { | ||
| Log.d(NAME, "temporary") | ||
| override fun navigateToSettings() { | ||
| BrownfieldNavigationManager.getDelegate().navigateToSettings() | ||
| } | ||
|
|
||
| @ReactMethod | ||
| override fun navigateToReferrals(userId: String) { | ||
| BrownfieldNavigationManager.getDelegate().navigateToReferrals(userId) | ||
|
Comment on lines
+10
to
+16
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, revert |
||
| } | ||
|
|
||
| companion object { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import Foundation | ||
|
|
||
| @objc public protocol BrownfieldNavigationDelegate: AnyObject { | ||
|
|
||
| @objc func navigateToSettings() | ||
| @objc func navigateToReferrals(_ userId: String) | ||
|
Comment on lines
+4
to
+5
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, revert |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,12 @@ | |
|
|
||
| @implementation NativeBrownfieldNavigation | ||
|
|
||
| - (void)temporary { | ||
| NSLog(@"temporary"); | ||
| - (void)navigateToSettings { | ||
| [[[BrownfieldNavigationManager shared] getDelegate] navigateToSettings]; | ||
| } | ||
|
|
||
| - (void)navigateToReferrals:(NSString *)userId { | ||
| [[[BrownfieldNavigationManager shared] getDelegate] navigateToReferrals:userId]; | ||
|
Comment on lines
+11
to
+16
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, revert |
||
| } | ||
|
|
||
| - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import { TurboModuleRegistry, type TurboModule } from 'react-native'; | ||
|
|
||
| export interface Spec extends TurboModule { | ||
| temporary(): void; | ||
| navigateToSettings(): void; | ||
| navigateToReferrals(userId: string): void; | ||
|
Comment on lines
+4
to
+5
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, revert |
||
| } | ||
|
|
||
| export default TurboModuleRegistry.getEnforcing<Spec>( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| import NativeBrownfieldNavigation from './NativeBrownfieldNavigation'; | ||
|
|
||
| const BrownfieldNavigation = { | ||
| temporary: () => { | ||
| NativeBrownfieldNavigation.temporary(); | ||
| navigateToSettings: () => { | ||
| NativeBrownfieldNavigation.navigateToSettings(); | ||
| }, | ||
| navigateToReferrals: (userId: string) => { | ||
| NativeBrownfieldNavigation.navigateToReferrals(userId); | ||
|
Comment on lines
+4
to
+8
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, revert |
||
| }, | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a tongue twister ;) let's rename this to
preferEmbeddedBundleInDebug