Getting Started
This guide walks you through setting up Brownie from scratch - defining stores, generating native types, building XCFrameworks, and using shared state in both React Native and Swift.
Prerequisites
Before starting, ensure you have:
- Completed the React Native Brownfield Quick Start guide
- React Native project with
@callstack/react-native-brownfieldinstalled - Native iOS app (SwiftUI or UIKit)
- Xcode 15+
Step 1: Install Brownie
In your React Native project:
Step 2: Define Your Store
Create a store definition file with the .brownie.ts extension:
Import the store in your app entry point:
Step 3: Use the Store in React Native
Step 4: Build XCFrameworks
The CLI generates native types and builds everything into XCFrameworks:
This produces the following in ios/.brownfield/package/:
YourScheme.xcframework- Your React Native moduleBrownie.xcframework- Shared state libraryReactBrownfield.xcframework- Brownfield integrationhermesvm.xcframework- JavaScript engine (orhermes.xcframeworkfor RN < 0.82.0)
The package:ios command automatically runs brownfield codegen to generate Swift types from your .brownie.ts files.
Step 5: Add Frameworks to Native App
- Open your native Xcode project
- Drag all XCFrameworks from
ios/.brownfield/package/into your project - In target settings → General → Frameworks, Libraries, and Embedded Content, set all to Embed & Sign
Step 6: Register Store in Swift
In your app's entry point, register the store with initial state:
Step 7: Use the Store in SwiftUI
Done!
State changes now sync automatically between React Native and Swift. Increment from either side and both update immediately.
Next Steps
- Defining Stores - Nested objects and multiple stores
- TypeScript Usage - Advanced React Native patterns
- Swift Usage - UIKit integration and API reference
- XCFramework Packaging - SPM distribution and advanced options
