Skip to content

Commit 239f6cb

Browse files
authored
docs: housekeeping (#273)
* docs: update outdated packaging info * chore: typo in comment * fix(docs): update documentation * docs: compatibility between Brownfield 3 and RN 0.83.x * chore: fixes after CR
1 parent 54ab7ab commit 239f6cb

File tree

15 files changed

+127
-74
lines changed

15 files changed

+127
-74
lines changed

docs/docs/docs/api-reference/brownfield-navigation.mdx/javascript-usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Rerun codegen if any of these change:
4848
- Method return types
4949

5050
```bash
51-
yarn brownfield:navigation-codegen
51+
npx brownfield navigation:codegen
5252
```
5353

5454
## Common errors

docs/docs/docs/api-reference/brownie/codegen.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ The generated struct:
5454
- Conforms to `BrownieStoreProtocol` with auto-generated `storeName`
5555
- Uses mutable `var` properties
5656

57-
5857
## How It Works
5958

6059
1. CLI recursively finds all `*.brownie.ts` files

docs/docs/docs/api-reference/brownie/getting-started.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ The CLI generates native types and builds everything into XCFrameworks:
7373
npx brownfield package:ios --scheme YourScheme --configuration Release
7474
```
7575

76-
This produces the following in `ios/.brownfield/package/`:
76+
This produces the following in `ios/.brownfield/package/build/`:
7777

7878
- `YourScheme.xcframework` - Your React Native module
79-
- `Brownie.xcframework` - Shared state library
80-
- `ReactBrownfield.xcframework` - Brownfield integration
8179
- `hermesvm.xcframework` - JavaScript engine (or `hermes.xcframework` for RN < 0.82.0)
80+
- `ReactBrownfield.xcframework` - Brownfield integration
81+
- `Brownie.xcframework` - Shared state library (only when using the Brownie package)
82+
- `BrownfieldNavigation.xcframework` - Brownfield navigation integration (only when using the brownfield-navigation package)
83+
84+
The `ios/.brownfield/build/` directory contains the build cache.
8285

8386
:::info
8487
The `package:ios` command automatically runs `brownfield codegen` to generate Swift types from your `.brownie.ts` files.
@@ -87,7 +90,7 @@ The `package:ios` command automatically runs `brownfield codegen` to generate Sw
8790
## Step 5: Add Frameworks to Native App
8891

8992
1. Open your native Xcode project
90-
2. Drag all XCFrameworks from `ios/.brownfield/package/` into your project
93+
2. Drag all XCFrameworks from `ios/.brownfield/package/build/` into your project
9194
3. In target settings → **General****Frameworks, Libraries, and Embedded Content**, set all to **Embed & Sign**
9295

9396
## Step 6: Register Store in Swift

docs/docs/docs/api-reference/react-native-brownfield/java.mdx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ ReactNativeBrownfield.getShared()
158158

159159
Creates a React Native view with a given module name. It automatically uses an instance of React Native created in `initialize` method. This is useful when embedding React Native views directly in your native layouts.
160160

161-
| Param | Required | Type | Description |
162-
| ------------- | -------- | ------------------ | ---------------------------------------------------------- |
163-
| context | Yes | `Context` | Android context to create the view |
164-
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management |
165-
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry` |
166-
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component |
161+
| Param | Required | Type | Description |
162+
| ------------- | -------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
163+
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management. Required for proper lifecycle; may be null only when passing a custom `reactDelegate`. |
164+
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
165+
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component. |
166+
| reactDelegate | No | `ReactDelegateWrapper` | Optional custom delegate. If passed, the `activity` argument is ignored. |
167167

168168
Returns: `FrameLayout` - A view containing the React Native component.
169169

@@ -172,13 +172,25 @@ Returns: `FrameLayout` - A view containing the React Native component.
172172
```java
173173
// In a Fragment or Activity
174174
FrameLayout reactView = ReactNativeBrownfield.getShared().createView(
175-
context,
176175
activity,
177176
"ReactNative"
178177
);
179178
container.addView(reactView);
180179
```
181180

181+
```java
182+
// With initial properties
183+
Bundle props = new Bundle();
184+
props.putInt("score", 12);
185+
FrameLayout reactView = ReactNativeBrownfield.getShared().createView(
186+
activity,
187+
"ReactNative",
188+
null,
189+
props
190+
);
191+
container.addView(reactView);
192+
```
193+
182194
##### `postMessage`
183195

184196
Send a JSON string to the React Native JS layer. The message is delivered as a `brownfieldMessage` DeviceEventEmitter event and can be received using `ReactNativeBrownfield.onMessage()` on the JS side.

docs/docs/docs/api-reference/react-native-brownfield/javascript.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ ReactNativeBrownfield.setNativeBackGestureAndButtonEnabled(true);
3737
A method to pop to native screen used to push React Native experience.
3838

3939
```ts
40-
ReactNativeBrownfield.popToNative(animated: boolean);
40+
ReactNativeBrownfield.popToNative(animated?: boolean);
4141
```
4242

4343
**Parameters:**
4444

45-
| Param | Type | Description |
46-
| -------- | --------- | -------------------------------------------- |
47-
| animated | `boolean` | Whether to animate the transition (iOS only) |
45+
| Param | Type | Description |
46+
| -------- | --------- | ------------------------------------------------------------------------------------------------------ |
47+
| animated | `boolean` | Optional. Whether to animate the transition (iOS only). Defaults to `false`, has no effect on Android. |
4848

4949
**Example:**
5050

docs/docs/docs/api-reference/react-native-brownfield/kotlin.mdx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ ReactNativeBrownfield.shared
137137

138138
Creates a React Native view with a given module name. It automatically uses an instance of React Native created in `initialize` method. This is useful when embedding React Native views directly in your native layouts or Jetpack Compose UI.
139139

140-
| Param | Required | Type | Description |
141-
| ------------- | -------- | ------------------ | ---------------------------------------------------------- |
142-
| context | Yes | `Context` | Android context to create the view |
143-
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management |
144-
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry` |
145-
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component |
140+
| Param | Required | Type | Description |
141+
| ------------- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
142+
| activity | No | `FragmentActivity` | Activity hosting the view, used for lifecycle management. Required for proper lifecycle; may be null only when using a custom `reactDelegate`. |
143+
| moduleName | Yes | `String` | Name of React Native component registered to `AppRegistry`. |
144+
| launchOptions | No | `Bundle` | Initial properties to be passed to React Native component. |
145+
| reactDelegate | No | `ReactDelegateWrapper` | Optional custom delegate. If passed, the `activity` argument is ignored. |
146146

147147
Returns: `FrameLayout` - A view containing the React Native component.
148148

@@ -151,18 +151,28 @@ Returns: `FrameLayout` - A view containing the React Native component.
151151
```kotlin
152152
// In a Fragment or Activity
153153
val reactView = ReactNativeBrownfield.shared.createView(
154-
context,
155154
activity,
156155
"ReactNative"
157156
)
158157
container.addView(reactView)
159158
```
160159

160+
```kotlin
161+
// With initial properties
162+
val props = Bundle().apply { putInt("score", 12) }
163+
val reactView = ReactNativeBrownfield.shared.createView(
164+
activity,
165+
"ReactNative",
166+
launchOptions = props
167+
)
168+
container.addView(reactView)
169+
```
170+
161171
```kotlin
162172
// With Jetpack Compose
163173
AndroidView(
164-
factory = { context ->
165-
ReactNativeBrownfield.shared.createView(context, fragmentActivity, "ReactNative")
174+
factory = {
175+
ReactNativeBrownfield.shared.createView(fragmentActivity, "ReactNative")
166176
},
167177
modifier = Modifier.fillMaxSize()
168178
)

docs/docs/docs/api-reference/react-native-brownfield/objective-c.mdx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ A singleton that keeps an instance of `ReactNativeBrownfield` object.
2828

2929
#### Properties
3030

31-
| Property | Type | Default | Description |
32-
| ------------------ | ---------- | --------------- | --------------------------------------------------------- |
33-
| `entryFile` | `NSString` | `index` | Path to JavaScript root. |
34-
| `fallbackResource` | `NSString` | `nil` | Path to bundle fallback resource. |
35-
| `bundlePath` | `NSString` | `main.jsbundle` | Path to bundle fallback resource. |
36-
| `bundle` | `NSBundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. |
31+
| Property | Type | Default | Description |
32+
| ------------------- | ------------------ | --------------- | ------------------------------------------------------------------------------ |
33+
| `entryFile` | `NSString` | `index` | Path to JavaScript root. |
34+
| `bundlePath` | `NSString` | `main.jsbundle` | Path to JavaScript bundle file. |
35+
| `bundle` | `NSBundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. |
36+
| `bundleURLOverride` | `NSURL *(^)(void)` | `nil` | Dynamic bundle URL provider. When set, overrides default bundle load behavior. |
3737

3838
---
3939

@@ -43,10 +43,9 @@ A singleton that keeps an instance of `ReactNativeBrownfield` object.
4343

4444
Starts React Native, produces an instance of React Native. You can use it to initialize React Native in your app.
4545

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

5150
**Examples:**
5251

@@ -60,12 +59,6 @@ Starts React Native, produces an instance of React Native. You can use it to ini
6059
}];
6160
```
6261
63-
```objc
64-
[[ReactNativeBrownfield shared] startReactNative:^(void){
65-
NSLog(@"React Native started");
66-
}, launchOptions];
67-
```
68-
6962
##### `view`
7063
7164
Creates a React Native view for the specified module name.
@@ -82,6 +75,17 @@ Creates a React Native view for the specified module name.
8275
UIView *view = [[ReactNativeBrownfield shared] viewWithModuleName:@"ReactNative" initialProps:@{@"score": @12}];
8376
```
8477

78+
##### `application:didFinishLaunchingWithOptions:`
79+
80+
Mirrors the host runtime app delegate API. Call this from your `AppDelegate` if you need to forward launch options to the brownfield runtime (e.g. when using Expo).
81+
82+
| Param | Required | Type | Description |
83+
| --------------- | -------- | ----------------- | -------------------------- |
84+
| `application` | Yes | `UIApplication *` | The application instance. |
85+
| `launchOptions` | No | `NSDictionary *` | Launch options dictionary. |
86+
87+
Returns: `BOOL` – return value is passed through from the runtime.
88+
8589
##### `postMessage`
8690

8791
Send a JSON string to the React Native JS layer. The message is delivered as a `brownfieldMessage` DeviceEventEmitter event.

docs/docs/docs/api-reference/react-native-brownfield/swift.mdx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ ReactNativeBrownfield.shared
3131
| Property | Type | Default | Description |
3232
| ------------------- | --------------- | --------------- | ---------------------------------------------------------------------------------------------- |
3333
| `entryFile` | `String` | `index` | Path to JavaScript root. |
34-
| `fallbackResource` | `String?` | `nil` | Path to bundle fallback resource. |
35-
| `bundlePath` | `String` | `main.jsbundle` | Path to bundle fallback resource. |
34+
| `bundlePath` | `String` | `main.jsbundle` | Path to JavaScript bundle file. |
3635
| `bundle` | `Bundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. |
3736
| `bundleURLOverride` | `(() -> URL?)?` | `nil` | Dynamic bundle URL provider called on every bundle load. When set, overrides default behavior. |
3837

@@ -44,10 +43,9 @@ ReactNativeBrownfield.shared
4443

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

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

5250
**Examples:**
5351

@@ -61,12 +59,6 @@ ReactNativeBrownfield.shared.startReactNative(onBundleLoaded: {
6159
})
6260
```
6361

64-
```swift
65-
ReactNativeBrownfield.shared.startReactNative(onBundleLoaded: {
66-
print("React Native started")
67-
}, launchOptions: launchOptions)
68-
```
69-
7062
##### `view`
7163

7264
Creates a React Native view for the specified module name.
@@ -105,6 +97,28 @@ let json = try! JSONSerialization.data(withJSONObject: payload)
10597
ReactNativeBrownfield.shared.postMessage(String(data: json, encoding: .utf8)!)
10698
```
10799

100+
##### `application(_:didFinishLaunchingWithOptions:)`
101+
102+
Mirrors the host runtime app delegate API. Call this from your `AppDelegate` if you need to forward `application(_:didFinishLaunchingWithOptions:)` to the brownfield runtime (e.g. when using Expo).
103+
104+
| Param | Required | Type | Description |
105+
| --------------- | -------- | ---------------------------------------- | -------------------------- |
106+
| `application` | Yes | `UIApplication` | The application instance. |
107+
| `launchOptions` | No | `[UIApplication.LaunchOptionsKey: Any]?` | Launch options dictionary. |
108+
109+
Returns: `Bool` – return value is passed through from the runtime.
110+
111+
**Example:**
112+
113+
```swift
114+
func application(
115+
_ application: UIApplication,
116+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
117+
) -> Bool {
118+
return ReactNativeBrownfield.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
119+
}
120+
```
121+
108122
##### `onMessage`
109123

110124
Subscribe to messages sent from JavaScript via `ReactNativeBrownfield.postMessage()`. Returns an observer token that can be used to unsubscribe.

0 commit comments

Comments
 (0)