Skip to content

Commit c60339b

Browse files
committed
feat: package brownie as xcframework
1 parent cf99055 commit c60339b

18 files changed

Lines changed: 974 additions & 62 deletions

File tree

apps/AppleApp/Brownfield Apple App.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
798DE8DB2F0EC98F00CFC6F3 /* hermesvm.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A9BC7F2EF5781F009EC2E3 /* hermesvm.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1414
798DE8DC2F0EC99000CFC6F3 /* ReactBrownfield.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A9BC802EF5781F009EC2E3 /* ReactBrownfield.xcframework */; };
1515
798DE8DD2F0EC99000CFC6F3 /* ReactBrownfield.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A9BC802EF5781F009EC2E3 /* ReactBrownfield.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
16+
79A9BC812EF5781F009EC2E3 /* Brownie.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A9BC822EF5781F009EC2E3 /* Brownie.xcframework */; };
17+
79A9BC832EF5781F009EC2E3 /* Brownie.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A9BC822EF5781F009EC2E3 /* Brownie.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1618
/* End PBXBuildFile section */
1719

1820
/* Begin PBXCopyFilesBuildPhase section */
@@ -25,6 +27,7 @@
2527
798DE8DB2F0EC98F00CFC6F3 /* hermesvm.xcframework in Embed Frameworks */,
2628
798DE8DD2F0EC99000CFC6F3 /* ReactBrownfield.xcframework in Embed Frameworks */,
2729
798DE8D82F0EC98E00CFC6F3 /* BrownfieldLib.xcframework in Embed Frameworks */,
30+
79A9BC832EF5781F009EC2E3 /* Brownie.xcframework in Embed Frameworks */,
2831
);
2932
name = "Embed Frameworks";
3033
runOnlyForDeploymentPostprocessing = 0;
@@ -36,6 +39,7 @@
3639
79A9BC7E2EF5781F009EC2E3 /* BrownfieldLib.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BrownfieldLib.xcframework; path = ../RNApp/ios/.brownfield/package/BrownfieldLib.xcframework; sourceTree = SOURCE_ROOT; };
3740
79A9BC7F2EF5781F009EC2E3 /* hermesvm.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = hermesvm.xcframework; path = ../RNApp/ios/.brownfield/package/hermesvm.xcframework; sourceTree = SOURCE_ROOT; };
3841
79A9BC802EF5781F009EC2E3 /* ReactBrownfield.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = ReactBrownfield.xcframework; path = ../RNApp/ios/.brownfield/package/ReactBrownfield.xcframework; sourceTree = SOURCE_ROOT; };
42+
79A9BC822EF5781F009EC2E3 /* Brownie.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Brownie.xcframework; path = ../RNApp/ios/.brownfield/package/Brownie.xcframework; sourceTree = SOURCE_ROOT; };
3943
/* End PBXFileReference section */
4044

4145
/* Begin PBXFileSystemSynchronizedRootGroup section */
@@ -54,6 +58,7 @@
5458
798DE8DA2F0EC98F00CFC6F3 /* hermesvm.xcframework in Frameworks */,
5559
798DE8DC2F0EC99000CFC6F3 /* ReactBrownfield.xcframework in Frameworks */,
5660
798DE8D72F0EC98E00CFC6F3 /* BrownfieldLib.xcframework in Frameworks */,
61+
79A9BC812EF5781F009EC2E3 /* Brownie.xcframework in Frameworks */,
5762
);
5863
runOnlyForDeploymentPostprocessing = 0;
5964
};
@@ -64,6 +69,7 @@
6469
isa = PBXGroup;
6570
children = (
6671
79A9BC7E2EF5781F009EC2E3 /* BrownfieldLib.xcframework */,
72+
79A9BC822EF5781F009EC2E3 /* Brownie.xcframework */,
6773
79A9BC7F2EF5781F009EC2E3 /* hermesvm.xcframework */,
6874
79A9BC802EF5781F009EC2E3 /* ReactBrownfield.xcframework */,
6975
793C76A92EEBF938008A2A34 /* Brownfield Apple App */,

apps/AppleApp/Brownfield Apple App/ContentView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ReactBrownfield
2+
import Brownie
23
import SwiftUI
34

45
struct ContentView: View {

apps/RNApp/App.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import React, { useEffect } from 'react';
2-
import { StyleSheet, Text, View, Button } from 'react-native';
1+
import { useEffect } from 'react';
2+
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
3+
import { useStore } from '@callstack/brownie';
34
import {
45
createNativeStackNavigator,
56
type NativeStackScreenProps,
67
} from '@react-navigation/native-stack';
78
import ReactNativeBrownfield from '@callstack/react-native-brownfield';
89
import { NavigationContainer } from '@react-navigation/native';
10+
import './BrownfieldStore.brownie';
911

1012
const getRandomValue = () => Math.round(Math.random() * 255);
1113
const getRandomTheme = () => {
@@ -26,6 +28,8 @@ type Props = NativeStackScreenProps<RootStackParamList, 'Home'>;
2628

2729
function HomeScreen({ navigation, route }: Props) {
2830
const colors = route.params?.theme || getRandomTheme();
31+
const [counter, setState] = useStore('BrownfieldStore', (s) => s.counter);
32+
const [user] = useStore('BrownfieldStore', (s) => s.user);
2933

3034
useEffect(() => {
3135
const unsubscribe = navigation.addListener('focus', () => {
@@ -37,10 +41,29 @@ function HomeScreen({ navigation, route }: Props) {
3741

3842
return (
3943
<View style={[styles.container, { backgroundColor: colors.primary }]}>
40-
<Text style={[styles.text, { color: colors.secondary }]}>
44+
<Text style={[styles.title, { color: colors.secondary }]}>
4145
React Native Screen
4246
</Text>
4347

48+
<Text style={[styles.text, { color: colors.secondary }]}>
49+
Count: {counter}
50+
</Text>
51+
52+
<TextInput
53+
style={styles.input}
54+
value={user.name}
55+
onChangeText={(text) =>
56+
setState((prev) => ({ user: { ...prev.user, name: text } }))
57+
}
58+
placeholder="User name"
59+
/>
60+
61+
<Button
62+
onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
63+
color={colors.secondary}
64+
title="Increment"
65+
/>
66+
4467
<Button
4568
onPress={() => {
4669
navigation.push('Home', {
@@ -87,9 +110,22 @@ const styles = StyleSheet.create({
87110
justifyContent: 'center',
88111
alignItems: 'center',
89112
},
90-
text: {
113+
title: {
91114
fontSize: 30,
92115
fontWeight: 'bold',
93116
margin: 10,
94117
},
118+
text: {
119+
fontSize: 16,
120+
margin: 5,
121+
},
122+
input: {
123+
borderWidth: 1,
124+
borderColor: '#ccc',
125+
borderRadius: 8,
126+
padding: 10,
127+
width: 200,
128+
marginVertical: 10,
129+
backgroundColor: '#fff',
130+
},
95131
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { BrownieStore } from '@callstack/brownie';
2+
3+
interface BrownfieldStore extends BrownieStore {
4+
counter: number;
5+
user: {
6+
name: string;
7+
};
8+
}
9+
10+
interface SettingsStore extends BrownieStore {
11+
theme: 'light' | 'dark';
12+
notificationsEnabled: boolean;
13+
privacyMode: boolean;
14+
}
15+
16+
declare module '@callstack/brownie' {
17+
interface BrownieStores {
18+
BrownfieldStore: BrownfieldStore;
19+
SettingsStore: SettingsStore;
20+
}
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.rnapp.brownfieldlib
2+
3+
data class BrownfieldStore (
4+
val counter: Double,
5+
val user: User
6+
) {
7+
companion object {
8+
const val STORE_NAME = "BrownfieldStore"
9+
}
10+
}
11+
12+
data class User (
13+
val name: String
14+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.rnapp.brownfieldlib
2+
3+
data class SettingsStore (
4+
val notificationsEnabled: Boolean,
5+
val privacyMode: Boolean,
6+
val theme: Theme
7+
) {
8+
companion object {
9+
const val STORE_NAME = "SettingsStore"
10+
}
11+
}
12+
13+
enum class Theme {
14+
Dark,
15+
Light
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Export helpers from @callstack/react-native-brownfield library
22
@_exported import ReactBrownfield
3+
@_exported import Brownie
34
// Initializes a Bundle instance that points at the framework target.
45
public let ReactNativeBundle = Bundle(for: InternalClassForBundle.self)
56
class InternalClassForBundle {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Brownie
2+
3+
// This file was generated from JSON Schema using quicktype, do not modify it directly.
4+
// To parse the JSON, add this file to your project and do:
5+
//
6+
// let brownfieldStore = try? JSONDecoder().decode(BrownfieldStore.self, from: jsonData)
7+
8+
//
9+
// Hashable or Equatable:
10+
// The compiler will not be able to synthesize the implementation of Hashable or Equatable
11+
// for types that require the use of JSONAny, nor will the implementation of Hashable be
12+
// synthesized for types that have collections (such as arrays or dictionaries).
13+
14+
import Foundation
15+
16+
// MARK: - BrownfieldStore
17+
struct BrownfieldStore: Codable, Equatable {
18+
var counter: Double
19+
var user: User
20+
}
21+
22+
//
23+
// Hashable or Equatable:
24+
// The compiler will not be able to synthesize the implementation of Hashable or Equatable
25+
// for types that require the use of JSONAny, nor will the implementation of Hashable be
26+
// synthesized for types that have collections (such as arrays or dictionaries).
27+
28+
// MARK: - User
29+
struct User: Codable, Equatable {
30+
var name: String
31+
}
32+
33+
extension BrownfieldStore: BrownieStoreProtocol {
34+
public static let storeName = "BrownfieldStore"
35+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Brownie
2+
3+
// This file was generated from JSON Schema using quicktype, do not modify it directly.
4+
// To parse the JSON, add this file to your project and do:
5+
//
6+
// let settingsStore = try? JSONDecoder().decode(SettingsStore.self, from: jsonData)
7+
8+
//
9+
// Hashable or Equatable:
10+
// The compiler will not be able to synthesize the implementation of Hashable or Equatable
11+
// for types that require the use of JSONAny, nor will the implementation of Hashable be
12+
// synthesized for types that have collections (such as arrays or dictionaries).
13+
14+
import Foundation
15+
16+
// MARK: - SettingsStore
17+
struct SettingsStore: Codable, Equatable {
18+
var notificationsEnabled, privacyMode: Bool
19+
var theme: Theme
20+
}
21+
22+
enum Theme: String, Codable, Equatable {
23+
case dark = "dark"
24+
case light = "light"
25+
}
26+
27+
extension SettingsStore: BrownieStoreProtocol {
28+
public static let storeName = "SettingsStore"
29+
}

apps/RNApp/ios/Podfile.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
PODS:
22
- boost (1.84.0)
3+
- Brownie (0.0.1):
4+
- boost
5+
- DoubleConversion
6+
- fast_float
7+
- fmt
8+
- glog
9+
- hermes-engine
10+
- RCT-Folly
11+
- RCT-Folly/Fabric
12+
- RCTRequired
13+
- RCTTypeSafety
14+
- React-Core
15+
- React-debug
16+
- React-Fabric
17+
- React-featureflags
18+
- React-graphics
19+
- React-ImageManager
20+
- React-jsi
21+
- React-NativeModulesApple
22+
- React-RCTFabric
23+
- React-renderercss
24+
- React-rendererdebug
25+
- React-utils
26+
- ReactCodegen
27+
- ReactCommon/turbomodule/bridging
28+
- ReactCommon/turbomodule/core
29+
- SocketRocket
30+
- Yoga
331
- DoubleConversion (1.1.6)
432
- fast_float (8.0.0)
533
- FBLazyVector (0.82.1)
@@ -2502,6 +2530,7 @@ PODS:
25022530

25032531
DEPENDENCIES:
25042532
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
2533+
- "Brownie (from `../node_modules/@callstack/brownie`)"
25052534
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
25062535
- fast_float (from `../node_modules/react-native/third-party-podspecs/fast_float.podspec`)
25072536
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
@@ -2587,6 +2616,8 @@ SPEC REPOS:
25872616
EXTERNAL SOURCES:
25882617
boost:
25892618
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
2619+
Brownie:
2620+
:path: "../node_modules/@callstack/brownie"
25902621
DoubleConversion:
25912622
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
25922623
fast_float:
@@ -2741,6 +2772,7 @@ EXTERNAL SOURCES:
27412772

27422773
SPEC CHECKSUMS:
27432774
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2775+
Brownie: 1429196bd3e48619a0b3cef86b601b288e8c0e36
27442776
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
27452777
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
27462778
FBLazyVector: 0aa6183b9afe3c31fc65b5d1eeef1f3c19b63bfa

0 commit comments

Comments
 (0)