Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/OBJECTIVE_C.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ Examples:

**Properties:**

| Property | Type | Default | Description |
| -------------------------- | ----------------------- | -------------- | -------------------------------------------------- |
| `entryFile` | `NSString` | `index` | Path to JavaScript root. |
| `fallbackResource` | `NSString` | `nil` | Path to bundle fallback resource. |
| `bundlePath` | `NSString` | `main.jsbundle`| Path to bundle fallback resource. |
| Property | Type | Default | Description |
| ------------------ | ---------- | --------------- | --------------------------------------------------------- |
| `entryFile` | `NSString` | `index` | Path to JavaScript root. |
| `fallbackResource` | `NSString` | `nil` | Path to bundle fallback resource. |
| `bundlePath` | `NSString` | `main.jsbundle` | Path to bundle fallback resource. |
| `bundle` | `NSBundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. |

---

Expand All @@ -46,10 +47,10 @@ Starts React Native, produces an instance of React Native. You can use it to ini

Params:

| Param | Required | Type | Description |
| ----------------------- | -------- | ----------------- | ----------------------------------------------------- |
| `onBundleLoaded` | No | `void(^)(void)` | Callback invoked after JS bundle is fully loaded. |
| `launchOptions` | No | `NSDictionary` | Launch options, typically passed from AppDelegate. |
| Param | Required | Type | Description |
| ---------------- | -------- | --------------- | -------------------------------------------------- |
| `onBundleLoaded` | No | `void(^)(void)` | Callback invoked after JS bundle is fully loaded. |
| `launchOptions` | No | `NSDictionary` | Launch options, typically passed from AppDelegate. |

Examples:

Expand All @@ -75,11 +76,11 @@ Creates a React Native view for the specified module name.

Params:

| Param | Required | Type | Description |
| ----------------------- | -------- | ----------------- | ----------------------------------------------------- |
| `moduleName` | Yes | `NSString` | Name of React Native component registered to `AppRegistry`. |
| `initialProps` | No | `NSDictionary` | Initial properties to be passed to React Native component. |
| `launchOptions` | No | `NSDictionary` | Launch options, typically passed from AppDelegate. |
| Param | Required | Type | Description |
| --------------- | -------- | -------------- | ----------------------------------------------------------- |
| `moduleName` | Yes | `NSString` | Name of React Native component registered to `AppRegistry`. |
| `initialProps` | No | `NSDictionary` | Initial properties to be passed to React Native component. |
| `launchOptions` | No | `NSDictionary` | Launch options, typically passed from AppDelegate. |

Examples:

Expand All @@ -105,10 +106,10 @@ You can import it from:

`[ReactNativeViewController initWithModuleName:moduleName andInitialProperties:initialProps]`

| Param | Required | Type | Description |
| --------------------- | --------- | --------------- | ------------------------------------------------------------- |
| `moduleName` | Yes | `NSString` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties` | No | `NSDictionary` | Initial properties to be passed to React Native component. |
| Param | Required | Type | Description |
| ------------------- | -------- | -------------- | ----------------------------------------------------------- |
| `moduleName` | Yes | `NSString` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties` | No | `NSDictionary` | Initial properties to be passed to React Native component. |

Examples:

Expand All @@ -119,4 +120,3 @@ Examples:
```objc
[[ReactNativeViewController alloc] initWithModuleName:@"ReactNative" andInitialProperties:@{@"score": @12}]
```

56 changes: 28 additions & 28 deletions docs/SWIFT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Swift

React Native Brownfield provides first-class support for Swift.
React Native Brownfield provides first-class support for Swift.

### API Reference

Expand Down Expand Up @@ -30,27 +30,27 @@ ReactNativeBrownfield.shared

**Properties:**

| Property | Type | Default | Description |
| -------------------------- | ----------------------- | -------------- | -------------------------------------------------- |
| `entryFile` | `String` | index | Path to JavaScript root. |
| `fallbackResource` | `String?` | nil | Path to bundle fallback resource. |
| `bundlePath` | `String` | main.jsbundle | Path to bundle fallback resource. |
| Property | Type | Default | Description |
| ------------------ | --------- | --------------- | --------------------------------------------------------- |
| `entryFile` | `String` | `index` | Path to JavaScript root. |
| `fallbackResource` | `String?` | `nil` | Path to bundle fallback resource. |
| `bundlePath` | `String` | `main.jsbundle` | Path to bundle fallback resource. |
| `bundle` | `Bundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. |

---

**Methods:**


`startReactNative`

Starts React Native. You can use it to initialize React Native in your app.

Params:

| Param | Required | Type | Description |
| ----------------------- | -------- | ------------------- | ----------------------------------------------------- |
| `onBundleLoaded` | No | `(() -> Void)?` | Callback invoked after JS bundle is fully loaded. |
| `launchOptions` | No | `[AnyHashable: Any]?` | Launch options, typically passed from AppDelegate. |
| Param | Required | Type | Description |
| ---------------- | -------- | --------------------- | -------------------------------------------------- |
| `onBundleLoaded` | No | `(() -> Void)?` | Callback invoked after JS bundle is fully loaded. |
| `launchOptions` | No | `[AnyHashable: Any]?` | Launch options, typically passed from AppDelegate. |

Examples:

Expand All @@ -76,11 +76,11 @@ Creates a React Native view for the specified module name.

Params:

| Param | Required | Type | Description |
| ----------------------- | -------- | ------------------- | ----------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProps` | No | `[AnyHashable: Any]?` | Initial properties to be passed to React Native component. |
| `launchOptions` | No | `[AnyHashable: Any]?` | Launch options, typically passed from AppDelegate. |
| Param | Required | Type | Description |
| --------------- | -------- | --------------------- | ----------------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProps` | No | `[AnyHashable: Any]?` | Initial properties to be passed to React Native component. |
| `launchOptions` | No | `[AnyHashable: Any]?` | Launch options, typically passed from AppDelegate. |

Examples:

Expand All @@ -105,7 +105,7 @@ import ReactBrownfield

class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ReactNativeBrownfield.shared.startReactNative {
print("React Native bundle loaded")
Expand All @@ -124,7 +124,7 @@ import ReactBrownfield
class ViewController: UIViewController {
@IBAction func openReactNativeScreen(_ sender: UIButton) {
let reactNativeVC = ReactNativeViewController(moduleName: "ReactNative")

present(reactNativeVC, animated: true)
}
}
Expand All @@ -143,7 +143,7 @@ struct MyApp: App {
print("React Native bundle loaded")
}
}

var body: some Scene {
WindowGroup {
ContentView()
Expand All @@ -164,7 +164,7 @@ struct ContentView: View {
VStack {
Text("Welcome to the Native App")
.padding()

NavigationLink("Push React Native Screen") {
ReactNativeView(moduleName: "ReactNative")
.navigationBarHidden(true)
Expand Down Expand Up @@ -197,10 +197,10 @@ import ReactBrownfield

`ReactNativeViewController(moduleName: moduleName, initialProperties: initialProperties)`

| Param | Required | Type | Description |
| ------------------ | --------- | --------------- | ------------------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties`| No | `[String: Any]?`| Initial properties to be passed to React Native component. |
| Param | Required | Type | Description |
| ------------------- | -------- | ---------------- | ----------------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties` | No | `[String: Any]?` | Initial properties to be passed to React Native component. |

Examples:

Expand Down Expand Up @@ -230,10 +230,10 @@ import ReactBrownfield

`ReactNativeView(moduleName: moduleName, initialProperties: initialProperties)`

| Param | Required | Type | Description |
| ------------------- | --------- | -------------- | ------------------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties` | No | `[String: Any]`| Initial properties to be passed to React Native component. |
| Param | Required | Type | Description |
| ------------------- | -------- | --------------- | ----------------------------------------------------------- |
| `moduleName` | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
| `initialProperties` | No | `[String: Any]` | Initial properties to be passed to React Native component. |

Examples:

Expand Down
12 changes: 11 additions & 1 deletion ios/ReactNativeBrownfield.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ internal import ReactAppDependencyProvider
class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
var entryFile = "index"
var bundlePath = "main.jsbundle"
var bundle = Bundle.main
// MARK: - RCTReactNativeFactoryDelegate Methods

override func sourceURL(for bridge: RCTBridge) -> URL? {
Expand All @@ -21,7 +22,7 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
let resourceName = withoutLast.joined()
let fileExtension = resourceURLComponents.last ?? ""

return Bundle.main.url(forResource: resourceName, withExtension: fileExtension)
return bundle.url(forResource: resourceName, withExtension: fileExtension)
#endif
}
}
Expand Down Expand Up @@ -54,6 +55,15 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
delegate.bundlePath = bundlePath
}
}
/**
* Bundle instance to lookup the JavaScript bundle.
* Default value: Bundle.main
*/
@objc public var bundle: Bundle = Bundle.main {
didSet {
delegate.bundle = bundle
}
}
/**
* React Native factory instance created when starting React Native.
* Default value: nil
Expand Down
Loading